fix parsing of non-decimal integers in configuration files

safe_strtoll() now accepts numbers in any base. It formerly assumed that
its input was a decimal number, which had the consequence that
hexadecimal or octal numbers would be parsed as strings when occurring
outside of parameter lists.

This obsoletes some workarounds in the file permission parsing code that
relied on this bug.
This commit is contained in:
Clemens Ladisch 2006-09-18 17:57:58 +02:00
parent a7bc1dd80c
commit 0211bc3b68
3 changed files with 10 additions and 18 deletions

View file

@ -470,7 +470,7 @@ static int safe_strtoll(const char *str, long long *val)
if (!*str)
return -EINVAL;
errno = 0;
if (sscanf(str, "%Ld%n", &v, &endidx) < 1)
if (sscanf(str, "%Li%n", &v, &endidx) < 1)
return -EINVAL;
if (str[endidx])
return -EINVAL;