* [PATCH 1/4] Btrfs-progs: add check for level and id in case overflow happens
@ 2013-02-25 14:02 Wang Shilong
0 siblings, 0 replies; only message in thread
From: Wang Shilong @ 2013-02-25 14:02 UTC (permalink / raw)
To: linux-btrfs; +Cc: wangshilong1991
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2013-02-25 14:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-25 14:02 [PATCH 1/4] Btrfs-progs: add check for level and id in case overflow happens Wang Shilong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).