summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGui Hecheng <guihc.fnst@cn.fujitsu.com>2014-04-21 20:13:31 +0800
committerDavid Sterba <dsterba@suse.cz>2014-05-02 17:04:09 +0200
commit4dbbcafd95f3371d9baef60fa3dd2083e4fb836a (patch)
treeb5c6b5d895f1855a62ed04d3b53194af172904e9
parentdae7456c7f3990d264d546e03375e4def3e646a6 (diff)
btrfs-progs: fix wrong max system array size check in user space
For system chunk array, We copy a "disk_key" and an chunk item each time, so there should be enough space to hold both of them, not only the chunk item. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--volumes.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/volumes.c b/volumes.c
index 77ffd325..b39f3743 100644
--- a/volumes.c
+++ b/volumes.c
@@ -630,7 +630,8 @@ int btrfs_add_system_chunk(struct btrfs_trans_handle *trans,
u8 *ptr;
array_size = btrfs_super_sys_array_size(super_copy);
- if (array_size + item_size > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE)
+ if (array_size + item_size + sizeof(disk_key)
+ > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE)
return -EFBIG;
ptr = super_copy->sys_chunk_array + array_size;