restore: don't corrupt stack for a zero-length command-line argument
Given a zero-length directory name, the trailing-slash removal code would test dir_name[-1], and if it were found to be a slash, would set it to '\0'. Reviewed-by: Josef Bacik <josef@redhat.com>
This commit is contained in:
parent
6fc24e4a70
commit
47f029cc8b
|
@ -849,11 +849,9 @@ int main(int argc, char **argv)
|
||||||
strncpy(dir_name, argv[optind + 1], 128);
|
strncpy(dir_name, argv[optind + 1], 128);
|
||||||
|
|
||||||
/* Strip the trailing / on the dir name */
|
/* Strip the trailing / on the dir name */
|
||||||
while (1) {
|
len = strlen(dir_name);
|
||||||
len = strlen(dir_name);
|
while (len && dir_name[--len] == '/') {
|
||||||
if (dir_name[len - 1] != '/')
|
dir_name[len] = '\0';
|
||||||
break;
|
|
||||||
dir_name[len - 1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (find_dir) {
|
if (find_dir) {
|
||||||
|
|
Loading…
Reference in a new issue