* [PATCH] fix errno use after strtoull
@ 2016-04-21 16:22 Ryan Harper
2016-04-23 23:46 ` FUJITA Tomonori
0 siblings, 1 reply; 2+ messages in thread
From: Ryan Harper @ 2016-04-21 16:22 UTC (permalink / raw)
To: stgt; +Cc: Stas Sergeev
[-- 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 --]
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] fix errno use after strtoull
2016-04-21 16:22 [PATCH] fix errno use after strtoull Ryan Harper
@ 2016-04-23 23:46 ` FUJITA Tomonori
0 siblings, 0 replies; 2+ messages in thread
From: FUJITA Tomonori @ 2016-04-23 23:46 UTC (permalink / raw)
To: ryan.harper; +Cc: stgt, stsp
On Thu, 21 Apr 2016 11:22:40 -0500
Ryan Harper <ryan.harper@canonical.com> wrote:
> 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(-)
Applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-23 23:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-21 16:22 [PATCH] fix errno use after strtoull Ryan Harper
2016-04-23 23:46 ` FUJITA Tomonori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox