diff mbox

libext2fs: fix dict_uint_cmp()

Message ID 536AEE3D.6090502@gmail.com
State Superseded, archived
Headers show

Commit Message

Niu Yawei May 8, 2014, 2:38 a.m. UTC
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(-)

Comments

Theodore Ts'o May 12, 2014, 12:16 p.m. UTC | #1
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
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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)