mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04: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)
|
||||
{
|
||||
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue