]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libquota: fix dict_uint_cmp()
authorNiu Yawei <yawei.niu@gmail.com>
Thu, 8 May 2014 02:38:53 +0000 (10:38 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 10 May 2014 02:11:25 +0000 (22:11 -0400)
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.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/quota/mkquota.c

index 9883216102a2b7d8cf2cbbe4b853ca5628a499e0..ba8c2da6a198cfd932169d02a329d119a8da7b74 100644 (file)
@@ -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)