Skip to contentSkip to conversation

libext2fs: fix dict_uint_cmp()

PATCH Applied Niu Yawei 2 participants 2 messages May 8, 2014 – May 12, 2014

lore
Share & tools
lore

Niu Yawei

author
#0 lore raw

PATCH 1/1 libext2fs: fix dict_uint_cmp()

dict_uint_cmp() returns an usigned int value in int type, which could mess the dict key comparison when the difference of two keys is greater than INT_MAX.

---
 lib/quota/mkquota.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
lib/quota/mkquota.c +6 -1
index 9883216..ba8c2da 100644
@@ -207,7 +207,12 @@ static int dict_uint_cmp(const void *a, const void *b)
 	c = VOIDPTR_TO_UINT(a);
 	d = VOIDPTR_TO_UINT(b);
 
-	return c - d;
+	if (c == d)
+		return 0;
+	else if (c > d)
+		return 1;
+	else
+		return -1;
 }
 
 static inline qid_t get_qid(struct ext2_inode *inode, int qtype)
Signature · 1 line
1.7.1
#1 lore raw
Quoted 5 lines · Niu Yawei

dict_uint_cmp() returns an usigned int value in int type, which could mess the dict key comparison when the difference of two keys is greater than INT_MAX.

Applied, thanks!

- Ted