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) ...@@ -517,6 +517,7 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
{ {
const char *str = buf; const char *str = buf;
char *next; char *next;
char digit;
int num = 0; int num = 0;
int qualifier; int qualifier;
int base; int base;
...@@ -638,12 +639,16 @@ int vsscanf(const char * buf, const char * fmt, va_list args) ...@@ -638,12 +639,16 @@ int vsscanf(const char * buf, const char * fmt, va_list args)
while (isspace(*str)) while (isspace(*str))
str++; str++;
if (!*str digit = *str;
|| (base == 16 && !isxdigit(*str)) if (is_sign && digit == '-')
|| (base == 10 && !isdigit(*str)) digit = *(str + 1);
|| (base == 8 && (!isdigit(*str) || *str > '7'))
|| (base == 0 && !isdigit(*str))) if (!digit
break; || (base == 16 && !isxdigit(digit))
|| (base == 10 && !isdigit(digit))
|| (base == 8 && (!isdigit(digit) || digit > '7'))
|| (base == 0 && !isdigit(digit)))
break;
switch(qualifier) { switch(qualifier) {
case 'h': case 'h':
......
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