]> git.alsa-project.org Git - alsa-lib.git/commitdiff
fixed safe_strtoll to check the following characters.
authorTakashi Iwai <tiwai@suse.de>
Wed, 3 Jul 2002 09:23:36 +0000 (09:23 +0000)
committerTakashi Iwai <tiwai@suse.de>
Wed, 3 Jul 2002 09:23:36 +0000 (09:23 +0000)
src/conf.c

index aeefa3fa5265ffcdb0246aed8c5341bf715b42e9..a71219a020c8188719bfa154e0cd6edfc6140e75 100644 (file)
@@ -463,10 +463,13 @@ typedef struct {
 int safe_strtoll(const char *str, long long *val)
 {
        long long v;
+       int endidx;
        if (!*str)
                return -EINVAL;
        errno = 0;
-       if (sscanf(str, "%Ld", &v) != 1)
+       if (sscanf(str, "%Ld%n", &v, &endidx) < 1)
+               return -EINVAL;
+       if (str[endidx])
                return -EINVAL;
        *val = v;
        return 0;