When parse_value finds something looking like a number, it first calls
safe_strtoll to test whether the value's type is integer.
Unfortunately, safe_strtoll simply grabs anything which may be an
integer, and doesn't check for any following characters (e.g. the
decimal point of a floating point number).

This means that all floating point numbers are parsed as integers.

The patch adds a check for the end of the string, similar to
safe_strtol and safe_strtod.


--- alsa-lib/src/conf.c.org     Tue Jul  2 00:39:34 2002
+++ alsa-lib/src/conf.c Tue Jul  2 00:52:22 2002
@@ -463,11 +463,14 @@
 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;
 }


Clemens


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Alsa-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

Reply via email to