mirror of
https://github.com/fluencelabs/musl
synced 2025-06-28 14:11:56 +00:00
fix scanf handling of "0" (followed by immediate EOF) with "%x"
other cases with %x were probably broken too. I would actually like to go ahead and replace this code in scanf with calls to the new __intparse framework, but for now this calls for a quick and unobtrusive fix without the risk of breaking other things.
This commit is contained in:
@ -319,34 +319,29 @@ int __scanf(rctx_t *r, const wchar_t *fmt, va_list ap)
|
|||||||
unread(r);
|
unread(r);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
m = 1;
|
||||||
if (((c=read(r))|0x20) != 'x') {
|
if (((c=read(r))|0x20) != 'x') {
|
||||||
if (t == 'i') {
|
if (t == 'i') t = 'o';
|
||||||
t = 'o';
|
|
||||||
/* lone 0 is valid octal */
|
|
||||||
if ((unsigned)(c-'0') >= 8) {
|
|
||||||
m = 1;
|
|
||||||
goto int_finish;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unread(r);
|
unread(r);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
t = 'x';
|
t = 'x';
|
||||||
|
m = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'u':
|
case 'u':
|
||||||
for (m=0; isdigit(c=read(r)); m=1)
|
for (; isdigit(c=read(r)); m=1)
|
||||||
i = 10*i + c-'0';
|
i = 10*i + c-'0';
|
||||||
goto int_finish;
|
goto int_finish;
|
||||||
case 'o':
|
case 'o':
|
||||||
for (m=0; (unsigned)(c=read(r))-'0' < 8; m=1)
|
for (; (unsigned)(c=read(r))-'0' < 8; m=1)
|
||||||
i = (i<<3) + c-'0';
|
i = (i<<3) + c-'0';
|
||||||
goto int_finish;
|
goto int_finish;
|
||||||
case 'x':
|
case 'x':
|
||||||
for (m=0; ; m=1) {
|
for (; ; m=1) {
|
||||||
if (isdigit(c=read(r))) {
|
if (isdigit(c=read(r))) {
|
||||||
i = (i<<4) + c-'0';
|
i = (i<<4) + c-'0';
|
||||||
} else if ((unsigned)(c|0x20)-'a' < 6) {
|
} else if ((unsigned)(c|0x20)-'a' < 6) {
|
||||||
|
Reference in New Issue
Block a user