Skip to contentSkip to conversation

Btrfs-progs: add check for level and id in case overflow happens

PATCH New Wang Shilong 1 participant 1 message Feb 25, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

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

From: Wang Shilong <[email protected]>

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.

---
 qgroup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
qgroup.c +2 -2
index dafde12..fbb50ab 100644
@@ -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;
Signature · 1 line
1.7.7.6