]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib: [strutils.c] more robust strtol checks
authorKarel Zak <kzak@redhat.com>
Mon, 21 Feb 2011 14:35:04 +0000 (15:35 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 21 Feb 2011 14:35:04 +0000 (15:35 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/strutils.c

index acb7139dc22a2e9f3cecb82fcc4152fd083e864f..21c58daeacae4797bb2f8c62e8e5002306c5f27f 100644 (file)
@@ -177,7 +177,7 @@ long strtol_or_err(const char *str, const char *errmesg)
        errno = 0;
        num = strtol(str, &end, 10);
 
-       if (errno || (end && *end))
+       if (errno || str == end || (end && *end))
                goto err;
 
        return num;
@@ -201,7 +201,7 @@ long long strtoll_or_err(const char *str, const char *errmesg)
        errno = 0;
        num = strtoll(str, &end, 10);
 
-       if (errno || (end && *end))
+       if (errno || str == end || (end && *end))
                goto err;
 
        return num;