* [PATCH] libext2fs: fix dict_uint_cmp()
@ 2014-05-08 2:38 Niu Yawei
2014-05-12 12:16 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Niu Yawei @ 2014-05-08 2:38 UTC (permalink / raw)
To: tytso, linux-ext4; +Cc: yawei.niu
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>
---
lib/quota/mkquota.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c
index 9883216..ba8c2da 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)
--
1.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libext2fs: fix dict_uint_cmp()
2014-05-08 2:38 [PATCH] libext2fs: fix dict_uint_cmp() Niu Yawei
@ 2014-05-12 12:16 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2014-05-12 12:16 UTC (permalink / raw)
To: Niu Yawei; +Cc: linux-ext4, yawei.niu
On Thu, May 08, 2014 at 10:38:53AM +0800, Niu Yawei wrote:
> 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>
Applied, thanks!
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-12 12:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-08 2:38 [PATCH] libext2fs: fix dict_uint_cmp() Niu Yawei
2014-05-12 12:16 ` Theodore Ts'o
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).