Wang Shilong
2013-Feb-25 14:02 UTC
[PATCH 1/4] Btrfs-progs: add check for level and id in case overflow happens
From: Wang Shilong <wangsl-fnst@cn.fujitsu.com> qgroupid(u64) is splitted into two parts: 1) the lower 48 bit are used to represent id 2) the higher 16 bit are used to represent level So the check for id and level are necessary. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> --- qgroup.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/qgroup.c b/qgroup.c index dafde12..fbb50ab 100644 --- a/qgroup.c +++ b/qgroup.c @@ -34,11 +34,11 @@ u64 parse_qgroupid(char *p) return id; } level = strtoull(p, &ptr_parse_end, 10); - if (ptr_parse_end != s) + if (ptr_parse_end != s || level >= (1ll << 16)) goto err; id = strtoull(s+1, &ptr_parse_end, 10); - if (ptr_parse_end != ptr_src_end) + if (ptr_parse_end != ptr_src_end || id >= (1ll << 48)) goto err; return (level << 48) | id; -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html