summaryrefslogtreecommitdiff
path: root/cmds-inspect.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-09-07 14:36:14 +0200
committerDavid Sterba <dsterba@suse.com>2016-09-21 14:12:38 +0200
commit939bc6323b701e860a4f45148d664c336c9c0afa (patch)
treea241bca459732c34b6eeecfa5c45ebf5dd67be9a /cmds-inspect.c
parentad44d1eb171a5ec1766d11d020324040cb51a436 (diff)
btrfs-progs: inspect: improved error handling
Two remaining BUG_ON, be more specific what's wrong. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-inspect.c')
-rw-r--r--cmds-inspect.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmds-inspect.c b/cmds-inspect.c
index 4b7cea07..d493544a 100644
--- a/cmds-inspect.c
+++ b/cmds-inspect.c
@@ -207,7 +207,10 @@ static int cmd_inspect_logical_resolve(int argc, char **argv)
ret = snprintf(full_path, bytes_left, "%s/", argv[optind+1]);
path_ptr = full_path + ret;
bytes_left -= ret + 1;
- BUG_ON(bytes_left < 0);
+ if (bytes_left < 0) {
+ error("path buffer too small: %d bytes", bytes_left);
+ goto out;
+ }
for (i = 0; i < inodes->elem_cnt; i += 3) {
u64 inum = inodes->val[i];
@@ -230,8 +233,12 @@ static int cmd_inspect_logical_resolve(int argc, char **argv)
path_ptr[-1] = '/';
ret = snprintf(path_ptr, bytes_left, "%s",
name);
- BUG_ON(ret >= bytes_left);
free(name);
+ if (ret >= bytes_left) {
+ error("path buffer too small: %d bytes",
+ bytes_left - ret);
+ goto out;
+ }
path_fd = btrfs_open_dir(full_path, &dirs, 1);
if (path_fd < 0) {
ret = -ENOENT;