From b014a6150ebaa97cee780fca184df626c173c30e Mon Sep 17 00:00:00 2001 From: Gui Hecheng Date: Mon, 21 Apr 2014 20:13:31 +0800 Subject: [PATCH 10/42] 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 Signed-off-by: David Sterba --- volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/volumes.c b/volumes.c index 77ffd3252c38..b39f374305bc 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; -- 1.9.0