SCSI target infrastructure mailing archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Apollon Oikonomopoulos <apollon@skroutz.gr>
To: stgt@vger.kernel.org
Cc: Stas Sergeev <stsp@users.sourceforge.net>,
	Ryan Harper <ryan.harper@canonical.com>,
	Apollon Oikonomopoulos <apoikos@debian.org>
Subject: [PATCH] Use ULLONG_MAX when checking for strtoull overflow
Date: Tue, 24 May 2016 12:15:04 +0300	[thread overview]
Message-ID: <1464081304-21761-1-git-send-email-apollon@skroutz.gr> (raw)

From: Apollon Oikonomopoulos <apoikos@debian.org>

According to strtoull(3):

 [...] Precisely the same holds for strtoull() (with ULLONG_MAX instead
 of ULONG_MAX).

Since we are using strtoull(3) and not strtoul(3), the check should be
made against ULLONG_MAX. Note that at least on amd64 ULONG_MAX and
ULLONG_MAX are the same, but this is not guaranteed to be the case for
other architectures as well.

Signed-off-by: Apollon Oikonomopoulos <apoikos@debian.org>
---
 usr/util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/util.h b/usr/util.h
index 019ff1c..256bdb8 100644
--- a/usr/util.h
+++ b/usr/util.h
@@ -148,7 +148,7 @@ struct signalfd_siginfo {
 	unsigned long long ull_val;     		\
 	ull_val = strtoull(str, &ptr, 0);       	\
 	val = (typeof(val)) ull_val;    		\
-	if (ull_val == ULONG_MAX || ptr == str)		\
+	if (ull_val == ULLONG_MAX || ptr == str)	\
 		ret = EINVAL;   			\
 	else if (val != ull_val)			\
 		ret = ERANGE;   			\
-- 
2.8.1

             reply	other threads:[~2016-05-24  9:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24  9:15 Apollon Oikonomopoulos [this message]
2016-06-02  2:11 ` [PATCH] Use ULLONG_MAX when checking for strtoull overflow FUJITA Tomonori

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=1464081304-21761-1-git-send-email-apollon@skroutz.gr \
    --to=apollon@skroutz.gr \
    --cc=apoikos@debian.org \
    --cc=ryan.harper@canonical.com \
    --cc=stgt@vger.kernel.org \
    --cc=stsp@users.sourceforge.net \
    /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 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 read-only IMAP folder(s) and NNTP newsgroup(s).