summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-09-07 16:09:11 +0200
committerDavid Sterba <dsterba@suse.com>2016-10-03 11:33:15 +0200
commit7b83595dbd6b6cbd8c449415e2e6dfaca0a80975 (patch)
treee294a8b845fed9ce3537b14ba427003359e503a0
parent689b6249f357d88fd7307cb6dab32b836f87c999 (diff)
btrfs-progs: corrupt-block: improved error handling in corrupt_item_nocow
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--btrfs-corrupt-block.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index 789cbc70..5e4ae72e 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -899,7 +899,11 @@ static int corrupt_item_nocow(struct btrfs_trans_handle *trans,
if (slot == 0)
del = 0;
/* Only accept valid eb */
- BUG_ON(!leaf->data || slot >= btrfs_header_nritems(leaf));
+ if (!leaf->data || slot >= btrfs_header_nritems(leaf)) {
+ error("invalid eb: no data or slot out of range: %d >= %d",
+ slot, btrfs_header_nritems(leaf));
+ return -EINVAL;
+ }
btrfs_item_key_to_cpu(leaf, &key, slot);
if (del) {
fprintf(stdout, "Deleting key and data [%llu, %u, %llu].\n",