1
1

Sync with gnulib 6ed53f13bc39d9a0252549e98a2a59441fb2351f.

lib/strutil/xstrtol.c: prohibit monstrosities like "1bB".

Problem reported by Young Mo Kang in: http://bugs.gnu.org/23388.

(xstrtoumax): Allow trailing second suffixes like "B" only if the first
suffix needs a base.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Этот коммит содержится в:
Andrew Borodin 2016-05-01 08:44:00 +03:00
родитель abbfde35b2
Коммит bdb81cd482

Просмотреть файл

@ -142,6 +142,20 @@ xstrtoumax (const char *s, char **ptr, int base, uintmax_t * val, const char *va
base = 1024; base = 1024;
switch (**p)
{
case 'E':
case 'G':
case 'g':
case 'k':
case 'K':
case 'M':
case 'm':
case 'P':
case 'T':
case 't':
case 'Y':
case 'Z':
if (strchr (valid_suffixes, '0') != NULL) if (strchr (valid_suffixes, '0') != NULL)
{ {
/* The "valid suffix" '0' is a special flag meaning that /* The "valid suffix" '0' is a special flag meaning that
@ -167,6 +181,9 @@ xstrtoumax (const char *s, char **ptr, int base, uintmax_t * val, const char *va
break; break;
} }
} }
default:
break;
}
switch (**p) switch (**p)
{ {
@ -175,6 +192,9 @@ xstrtoumax (const char *s, char **ptr, int base, uintmax_t * val, const char *va
break; break;
case 'B': case 'B':
/* This obsolescent first suffix is distinct from the 'B'
second suffix above. E.g., 'tar -L 1000B' means change
the tape after writing 1000 KiB of data. */
overflow = bkm_scale (&tmp, 1024); overflow = bkm_scale (&tmp, 1024);
break; break;