From: Clemens Ladisch <clemens@ladisch.de>
To: alsa-devel@alsa-project.org
Subject: [PATCH] conf.c: parsing floating point numbers
Date: Tue, 02 Jul 2002 10:52:03 +0200 [thread overview]
Message-ID: <3D2169B3.FA0D9F45@ladisch.de> (raw)
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
next reply other threads:[~2002-07-02 8:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-02 8:52 Clemens Ladisch [this message]
2002-07-03 9:23 ` [PATCH] conf.c: parsing floating point numbers Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3D2169B3.FA0D9F45@ladisch.de \
--to=clemens@ladisch.de \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.