Bug in Newlib's sscanf implementation

Niklas Eklund eklund.n@gmail.com
Fri Mar 9 15:13:00 GMT 2018


Hello.

In sscanf with following buffer to parse "0x0000" and format string "%x
%n", does not return expected result.

It is the value given by %n variable that is off-by-one (value is 5 instead
of expected 6). The value given by %x is correctly set to zero.

If the buffer to parse is any other value than just zeros, or without
leading 0x, it gives expected results. I think it might be the
NDIGITS/NZDIGITS/NNZDIGITS toggling that might throw of the increasing of
number of characters parsed. Or it is some final criteria that kicks in if
0x has been found and then only zeros.

Best regards.

Niklas Eklund



More information about the Newlib mailing list