aboutsummaryrefslogtreecommitdiffstats
path: root/volumes.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2015-11-30 16:44:29 +0100
committerDavid Sterba <dsterba@suse.com>2016-01-04 11:28:24 +0100
commit81e43dabc87ea9b2242456a8bbe9239e55cb841f (patch)
tree6aaca9ce103dc02d66b086ccb8c10979d474345a /volumes.c
parentd9463cfeaa9a131062752c1136825071137c78f5 (diff)
downloadbtrfs-progs-81e43dabc87ea9b2242456a8bbe9239e55cb841f.tar.gz
btrfs-progs-81e43dabc87ea9b2242456a8bbe9239e55cb841f.tar.xz
btrfs-progs-81e43dabc87ea9b2242456a8bbe9239e55cb841f.zip
btrfs-progs: handle invalid num_stripes in sys_array
We can handle the special case of num_stripes == 0 directly inside btrfs_read_sys_array. The BUG_ON in btrfs_chunk_item_size is there to catch other unhandled cases where we fail to validate external data, like in btrfs-show-super. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'volumes.c')
-rw-r--r--volumes.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/volumes.c b/volumes.c
index 32d9a5a..b4d489a 100644
--- a/volumes.c
+++ b/volumes.c
@@ -1839,6 +1839,14 @@ int btrfs_read_sys_array(struct btrfs_root *root)
goto out_short_read;
num_stripes = btrfs_chunk_num_stripes(sb, chunk);
+ if (!num_stripes) {
+ printk(
+ "ERROR: invalid number of stripes %u in sys_array at offset %u\n",
+ num_stripes, cur_offset);
+ ret = -EIO;
+ break;
+ }
+
len = btrfs_chunk_item_size(num_stripes);
if (cur_offset + len > array_size)
goto out_short_read;