[Bug 1547060] [NEW] cant use -d switch

Launchpad Bug Tracker 1547060 at bugs.launchpad.net
Thu Apr 21 16:24:34 UTC 2016


You have been subscribed to a public bug by Ubuntu Foundations Team Bug Bot (crichton):

tgt-1:1.0.62-1ubuntu2

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


The following change should fix the problem:

--- util.h.old  2015-12-02 03:27:15.000000000 +0300
+++ util.h      2016-02-18 18:04:08.749932076 +0300
@@ -148,7 +148,7 @@
        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;                           \


Here, the errno is checked incorrectly: you can't check
errno unless the returned value allows you to. In case
of strtoull(), errno should be checked only if ULONG_MAX is
returned.
I however can't test the fix properly because when compiled
from source, the bug doesn't happen. The value of errno is
unspecified, and it just happens to be 0 when I compile from
sources.

** Affects: tgt (Ubuntu)
     Importance: High
     Assignee: Ryan Harper (raharper)
         Status: Confirmed

** Affects: tgt (Debian)
     Importance: Unknown
         Status: Unknown


** Tags: patch
-- 
cant use -d switch
https://bugs.launchpad.net/bugs/1547060
You received this bug notification because you are a member of Ubuntu Sponsors Team, which is subscribed to the bug report.



More information about the Ubuntu-sponsors mailing list