Package: tgt
Version: 1:1.0.63-1
Severity: normal
Tags: patch
User: [email protected]
Usertags: origin-ubuntu ubuntu-patch
Dear Maintainer,
When attempting to use parameters with numbers, tgtd fails to parse them.
# ./tgtd -d 1
-d argument value '1' invalid
Try `tgtd --help' for more information.
This is due to improper use of errno after calling strtoull which
only sets errno when value is out of range (see man strtoull).
In Ubuntu, the attached patch was applied to achieve the following:
* debian/patches/util_strtoull_errno.patch by Stas Sergeev
- Fix errno handling for number * parsing (LP: #1547060)
Thanks for considering the patch.
-- System Information:
Debian Release: stretch/sid
APT prefers xenial-updates
APT policy: (500, 'xenial-updates'), (500, 'xenial-security'), (500,
'xenial'), (100, 'xenial-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 4.4.0-18-generic (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
diff -Nru tgt-1.0.63/debian/patches/series tgt-1.0.63/debian/patches/series
--- tgt-1.0.63/debian/patches/series 2016-03-30 01:20:59.000000000 -0500
+++ tgt-1.0.63/debian/patches/series 2016-04-21 09:13:03.000000000 -0500
@@ -3,3 +3,4 @@
use-dpkg-buildflags.patch
do-not-build-html-manpages.patch
fix-aio-detection.patch
+util_strtoull_errno.patch
diff -Nru tgt-1.0.63/debian/patches/util_strtoull_errno.patch tgt-1.0.63/debian/patches/util_strtoull_errno.patch
--- tgt-1.0.63/debian/patches/util_strtoull_errno.patch 1969-12-31 18:00:00.000000000 -0600
+++ tgt-1.0.63/debian/patches/util_strtoull_errno.patch 2016-04-21 09:28:19.000000000 -0500
@@ -0,0 +1,37 @@
+Description: fix errno check in util.h preventing numeric arg parsing
+ From 3f3991ee3345f9728928711f6be7a0020568faf6 Mon Sep 17 00:00:00 2001
+ From: Stas Sergeev <[email protected]>
+ 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.
+Author: Stas Sergeev <[email protected]>
+Origin: https://github.com/fujita/tgt/pull/18/commits/3f3991ee3345f9728928711f6be7a0020568faf6
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/tgt/+bug/1547060
+Last-Update: 20160421
+
+---
+ 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; \