summaryrefslogtreecommitdiff
path: root/cmds-scrub.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-08-26 12:53:31 +0200
committerDavid Sterba <dsterba@suse.com>2016-09-21 14:12:10 +0200
commit5b160549582fe3cd852ce501570232a1cc227338 (patch)
treede2c8e0b1741d65ce474fbcc76a885085bbcf002 /cmds-scrub.c
parent0ce97733feb1f96acd22ae01e0c7921b23f1c9ae (diff)
btrfs-progs: scrub: improved error handling in scrub_read_file
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-scrub.c')
-rw-r--r--cmds-scrub.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/cmds-scrub.c b/cmds-scrub.c
index c03bc5fb..2cf7f308 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -481,7 +481,10 @@ static struct scrub_file_record **scrub_read_file(int fd, int report_errors)
again:
old_avail = avail - i;
- BUG_ON(old_avail < 0);
+ if (old_avail < 0) {
+ error("scrub record file corrupted near byte %d", i);
+ return ERR_PTR(-EINVAL);
+ }
if (old_avail)
memmove(l, l + i, old_avail);
avail = read(fd, l + old_avail, sizeof(l) - old_avail);
@@ -650,7 +653,9 @@ skip:
} while (i < avail);
continue;
}
- BUG();
+ error("internal error: unknown parser state %d near byte %d",
+ state, i);
+ return ERR_PTR(-EINVAL);
}
goto again;
}