diff mbox

[1/4] Btrfs-progs: add check for level and id in case overflow happens

Message ID 1361800957-1947-1-git-send-email-wangshilong1991@gmail.com (mailing list archive)
State Under Review, archived
Headers show

Commit Message

Wang Shilong Feb. 25, 2013, 2:02 p.m. UTC
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 mbox

Patch

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;