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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wang Shilong <wangsl-fnst@xxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux