diff options
author | David Sterba <dsterba@suse.com> | 2016-10-19 12:38:10 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-10-25 14:28:36 +0200 |
commit | a0fabf5f1dfae13e4b668d07d68bd37c7e383bb5 (patch) | |
tree | ae6c164bad72e993b9151291810557525a84e287 /cmds-inspect-dump-tree.c | |
parent | dcc3df7e6d9467b61fb1dcce4bf653e835613e49 (diff) |
btrfs-progs: dump-tree: fix crash on unrecognized tree id
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-inspect-dump-tree.c')
-rw-r--r-- | cmds-inspect-dump-tree.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/cmds-inspect-dump-tree.c b/cmds-inspect-dump-tree.c index f43ef386..03aa0b27 100644 --- a/cmds-inspect-dump-tree.c +++ b/cmds-inspect-dump-tree.c @@ -260,26 +260,27 @@ int cmd_inspect_dump_tree(int argc, char **argv) case 'b': block_only = arg_strtou64(optarg); break; - case 't': - if (string_is_numerical(optarg)) { - tree_id = arg_strtou64(optarg); - } else { - const char *end = NULL; + case 't': { + const char *end = NULL; + if (string_is_numerical(optarg)) + tree_id = arg_strtou64(optarg); + else tree_id = treeid_from_string(optarg, &end); - if (*end) { - error("unexpected tree id suffix of '%s': %s\n", - optarg, end); - exit(1); - } - } if (!tree_id) { error("unrecognized tree id: %s\n", optarg); exit(1); } + + if (end && *end) { + error("unexpected tree id suffix of '%s': %s", + optarg, end); + exit(1); + } break; + } default: usage(cmd_inspect_dump_tree_usage); } |