[PATCH] fix errno use after strtoull

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxx>
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: signature.asc
Description: Digital signature


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux