Commit fc4088d8 authored by Randy Dunlap's avatar Randy Dunlap Committed by Christoph Hellwig

[PATCH] Fix sscanf("-1", "%d", &i)

parent f81154a9
......@@ -517,6 +517,7 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
{
const char *str = buf;
char *next;
char digit;
int num = 0;
int qualifier;
int base;
......@@ -638,11 +639,15 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
while (isspace(*str))
str++;
if (!*str
|| (base == 16 && !isxdigit(*str))
|| (base == 10 && !isdigit(*str))
|| (base == 8 && (!isdigit(*str) || *str > '7'))
|| (base == 0 && !isdigit(*str)))
digit = *str;
if (is_sign && digit == '-')
digit = *(str + 1);
if (!digit
|| (base == 16 && !isxdigit(digit))
|| (base == 10 && !isdigit(digit))
|| (base == 8 && (!isdigit(digit) || digit > '7'))
|| (base == 0 && !isdigit(digit)))
break;
switch(qualifier) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment