mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-16 09:46:55 +00:00
btrfs-progs: corrupt-block: fix the mismatch in --root and -r options
[BUG] The following command will crash: $ btrfs-corrupt-block --value 4308598784 --root 5 --inode 256 --file-extent 0 \ -f disk_bytenr ~/test.img [CAUSE] The backtrace is at the following code: case 'r': root_objectid = arg_strtou64(optarg); break; And @optarg is NULL. The root cause is, for short option "-r" it indeed requires an argument. But unfortunately for the longer version, it goes: { "root", no_argument, NULL, 'r'}, Thus it gave @optarg as NULL if we go the longer option and crash. [FIX] Just fix the argument requirement for "--root" option. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
5684d2f3d9
commit
b80c1d0c7f
@ -1346,7 +1346,7 @@ int main(int argc, char **argv)
|
||||
{ "item", no_argument, NULL, 'I'},
|
||||
{ "dir-item", no_argument, NULL, 'D'},
|
||||
{ "delete", no_argument, NULL, 'd'},
|
||||
{ "root", no_argument, NULL, 'r'},
|
||||
{ "root", required_argument, NULL, 'r'},
|
||||
{ "csum", required_argument, NULL, 'C'},
|
||||
{ "block-group", required_argument, NULL, GETOPT_VAL_BLOCK_GROUP},
|
||||
{ "value", required_argument, NULL, GETOPT_VAL_VALUE},
|
||||
|
Loading…
Reference in New Issue
Block a user