]> git.ipfire.org Git - thirdparty/glibc.git/commit
stdio-common: Reject significand prefixes in scanf [BZ #12701]
authorMaciej W. Rozycki <macro@redhat.com>
Fri, 28 Mar 2025 12:35:53 +0000 (12:35 +0000)
committerMaciej W. Rozycki <macro@redhat.com>
Fri, 28 Mar 2025 12:35:53 +0000 (12:35 +0000)
commit0b390b55085070bfa9598fb42049a32460681308
tree857f72cc94ef609ad1f418b0c10e5056812024dc
parente78cb4f6bd033b09eaf316057598df9315891860
stdio-common: Reject significand prefixes in scanf [BZ #12701]

Reject invalid formatted scanf real input data that is comprised of a
hexadecimal prefix, optionally preceded by a sign, and with no actual
digits following owing to the field width restriction in effect.  Such
data is a prefix of, but not a matching input sequence and it is
required by ISO C to cause a matching failure.

Currently a matching success is instead incorrectly produced along with
the conversion result of zero, with the prefix wholly consumed from
input.  Where the end of input is marked by the end-of-file condition
rather than the field width restriction in effect a matching failure is
already correctly produced.

Enable input data that causes test failures without this fix in place.

Reviewed-by: Joseph Myers <josmyers@redhat.com>
13 files changed:
stdio-common/vfscanf-internal.c
sysdeps/ieee754/dbl-64/tst-scanf-format-double-a.input
sysdeps/ieee754/dbl-64/tst-scanf-format-double-aa.input
sysdeps/ieee754/flt-32/tst-scanf-format-float-a.input
sysdeps/ieee754/flt-32/tst-scanf-format-float-aa.input
sysdeps/ieee754/ldbl-128/tst-scanf-format-ldouble-a.input
sysdeps/ieee754/ldbl-128/tst-scanf-format-ldouble-aa.input
sysdeps/ieee754/ldbl-128ibm/tst-scanf-format-ldouble-a.input
sysdeps/ieee754/ldbl-128ibm/tst-scanf-format-ldouble-aa.input
sysdeps/ieee754/ldbl-96/tst-scanf-format-ldouble-a.input
sysdeps/ieee754/ldbl-96/tst-scanf-format-ldouble-aa.input
sysdeps/ieee754/ldbl-opt/tst-scanf-format-ldouble-a.input
sysdeps/ieee754/ldbl-opt/tst-scanf-format-ldouble-aa.input