From: Takashi Iwai Date: Wed, 3 Jul 2002 09:23:36 +0000 (+0000) Subject: fixed safe_strtoll to check the following characters. X-Git-Tag: v1.0.3~406 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=f7267994832a1e3abddaf29a1c418bf4b3740b22;p=alsa-lib.git fixed safe_strtoll to check the following characters. --- diff --git a/src/conf.c b/src/conf.c index aeefa3fa..a71219a0 100644 --- a/src/conf.c +++ b/src/conf.c @@ -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;