From: Andreas Schwab Date: Thu, 31 Oct 2013 11:51:03 +0000 (+0100) Subject: Fix parsing of 0e+0 as float X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=92f45f230c8abdf91195f2f7e4f003754755a0c6;p=thirdparty%2Fglibc.git Fix parsing of 0e+0 as float --- diff --git a/ChangeLog b/ChangeLog index 2404b75d853..9124a19f6b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-10-31 Andreas Schwab + + [BZ# 15917] + * stdio-common/vfscanf.c (_IO_vfwscanf): Handle leading '0' not + followed by 'x' as part of digit sequence. + * stdio-common/tst-sscanf.c (double_tests2): New tests. + 2013-10-04 Adhemerval Zanella * sysdeps/powerpc/powerpc64/strcpy.S (strcpy): Add word load/store diff --git a/NEWS b/NEWS index c70f333cc49..8b228b0a25b 100644 --- a/NEWS +++ b/NEWS @@ -9,8 +9,8 @@ Version 2.18.1 * The following bugs are resolved with this release: - 14155, 14699, 15532, 15427, 15522, 15797, 15892, 15895, 15909, 15996, - 16072, 16150. + 14155, 14699, 15532, 15427, 15522, 15797, 15892, 15895, 15909, 15917, + 15996, 16072, 16150. * CVE-2013-4237 The readdir_r function could write more than NAME_MAX bytes to the d_name member of struct dirent, or omit the terminating NUL diff --git a/stdio-common/tst-sscanf.c b/stdio-common/tst-sscanf.c index 1edb2271992..3c34f58a635 100644 --- a/stdio-common/tst-sscanf.c +++ b/stdio-common/tst-sscanf.c @@ -109,6 +109,19 @@ struct test double_tests[] = { L("-inf"), L("%g"), 1 } }; +struct test2 +{ + const CHAR *str; + const CHAR *fmt; + int retval; + char residual; +} double_tests2[] = +{ + { L("0e+0"), L("%g%c"), 1, 0 }, + { L("0xe+0"), L("%g%c"), 2, '+' }, + { L("0x.e+0"), L("%g%c"), 2, '+' }, +}; + int main (void) { @@ -196,5 +209,26 @@ main (void) } } + for (i = 0; i < sizeof (double_tests2) / sizeof (double_tests2[0]); ++i) + { + double dummy; + int ret; + char c = 0; + + if ((ret = SSCANF (double_tests2[i].str, double_tests2[i].fmt, + &dummy, &c)) != double_tests2[i].retval) + { + printf ("double_tests2[%d] returned %d != %d\n", + i, ret, double_tests2[i].retval); + result = 1; + } + else if (ret == 2 && c != double_tests2[i].residual) + { + printf ("double_tests2[%d] stopped at '%c' != '%c'\n", + i, c, double_tests2[i].residual); + result = 1; + } + } + return result; } diff --git a/stdio-common/vfscanf.c b/stdio-common/vfscanf.c index 343056769eb..093c8b0c580 100644 --- a/stdio-common/vfscanf.c +++ b/stdio-common/vfscanf.c @@ -1966,6 +1966,8 @@ _IO_vfscanf_internal (_IO_FILE *s, const char *format, _IO_va_list argptr, if (width > 0) --width; } + else + got_digit = 1; } while (1)