mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-12-18 08:56:42 -05:00
fixed safe_strtoll to check the following characters.
This commit is contained in:
parent
46761b6ad3
commit
f726799483
1 changed files with 4 additions and 1 deletions
|
|
@ -463,10 +463,13 @@ typedef struct {
|
||||||
int safe_strtoll(const char *str, long long *val)
|
int safe_strtoll(const char *str, long long *val)
|
||||||
{
|
{
|
||||||
long long v;
|
long long v;
|
||||||
|
int endidx;
|
||||||
if (!*str)
|
if (!*str)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
if (sscanf(str, "%Ld", &v) != 1)
|
if (sscanf(str, "%Ld%n", &v, &endidx) < 1)
|
||||||
|
return -EINVAL;
|
||||||
|
if (str[endidx])
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
*val = v;
|
*val = v;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue