summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiu Yawei <yawei.niu@gmail.com>2014-05-08 10:38:53 +0800
committerTheodore Ts'o <tytso@mit.edu>2014-05-09 22:11:25 -0400
commit4cf0b0fe443566940098308c2a9eb28fdb000166 (patch)
tree5d0e79b9f2b681c2cbb81ada2887811f41f503be
parent4e2d9f7f4ed55e42ee42b39bb13ad7372b4f37a1 (diff)
downloade2fsprogs-4cf0b0fe443566940098308c2a9eb28fdb000166.tar.gz
libquota: 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. Signed-off-by: Niu Yawei <yawei.niu@intel.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--lib/quota/mkquota.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c
index 98832161..ba8c2da6 100644
--- a/lib/quota/mkquota.c
+++ b/lib/quota/mkquota.c
@@ -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)