public inbox for stgt@vger.kernel.org
 help / color / mirror / Atom feed
From: Ryan Harper <ryan.harper@canonical.com>
To: stgt@vger.kernel.org
Cc: Stas Sergeev <stsp@users.sourceforge.net>
Subject: [PATCH] fix errno use after strtoull
Date: Thu, 21 Apr 2016 11:22:40 -0500	[thread overview]
Message-ID: <20160421162240.GA15513@foudres> (raw)

[-- Attachment #1: Type: text/plain, Size: 1521 bytes --]

As described in this bug:

https://bugs.launchpad.net/ubuntu/+source/tgt/+bug/1547060

Patch comes from an outstanding pull request from Stas Sergeev here:

https://github.com/fujita/tgt/pull/18/

I've tested this patch and verified that it resolves the issue with use 
of parameters with numbers in our Ubuntu package.  I've also filed
a similar bug in Debian here:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=822160

Please consider accepting the patch.

-- 
Ryan Harper
Canonical, Ltd.

==

From 3f3991ee3345f9728928711f6be7a0020568faf6 Mon Sep 17 00:00:00 2001
From: Stas Sergeev <stsp@users.sourceforge.net>
Date: Thu, 18 Feb 2016 18:35:23 +0300
Subject: [PATCH] fix errno check

errno can only be checked if the return value indicates an error.
The result of this bug is the following:

 ./tgtd -d 1
-d argument value '1' invalid
Try `tgtd --help' for more information.

As can be seen, it rejects the valid parameter because errno just
happens to be non-zero.
---
 usr/util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr/util.h b/usr/util.h
index 0e34c35..019ff1c 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 (errno || ptr == str)			\
+	if (ull_val == ULONG_MAX || ptr == str)		\
 		ret = EINVAL;   			\
 	else if (val != ull_val)			\
 		ret = ERANGE;   			\

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

             reply	other threads:[~2016-04-21 16:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21 16:22 Ryan Harper [this message]
2016-04-23 23:46 ` [PATCH] fix errno use after strtoull 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=20160421162240.GA15513@foudres \
    --to=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