All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niu Yawei <yawei.niu@gmail.com>
To: tytso@mit.edu, linux-ext4@vger.kernel.org
Cc: yawei.niu@intel.com
Subject: [PATCH] libext2fs: fix dict_uint_cmp()
Date: Thu, 08 May 2014 10:38:53 +0800	[thread overview]
Message-ID: <536AEE3D.6090502@gmail.com> (raw)

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

             reply	other threads:[~2014-05-08  2:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-08  2:38 Niu Yawei [this message]
2014-05-12 12:16 ` [PATCH] libext2fs: fix dict_uint_cmp() Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=536AEE3D.6090502@gmail.com \
    --to=yawei.niu@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=yawei.niu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.