diff options
author | Maciej W. Rozycki <macro@redhat.com> | 2025-08-11 17:42:12 +0100 |
---|---|---|
committer | Maciej W. Rozycki <macro@redhat.com> | 2025-08-11 17:42:12 +0100 |
commit | b692181703e59174bdb3d9a5f696326f10f7a13b (patch) | |
tree | bb15aefe41f5379c565ea7a793c3cf1cb396ab46 /sysdeps/unix/sysv/linux/syslog.c | |
parent | 8543577b04ded6d979ffcc5a818930e4d74d0645 (diff) | |
download | glibc-b692181703e59174bdb3d9a5f696326f10f7a13b.zip glibc-b692181703e59174bdb3d9a5f696326f10f7a13b.tar.gz glibc-b692181703e59174bdb3d9a5f696326f10f7a13b.tar.bz2 |
stdio-common: Don't read real input beyond the field width in scanf
Fix a code pattern that repeats across '__vfscanf_internal' where the
remaining field width of 0 is incorrectly interpreted as no width limit,
which in turn results in reading input beyond the limit requested. The
lack of width limit is indicated by the field width of -1 rather than 0,
set earlier on in the function.
The problematic code pattern is used for both integer and floating-point
conversions, but in the former case a corresponding conditional earlier
on prevents the field width from being 0 when executing the pattern. It
does trigger in the latter case, where the decimal point is a multibyte
character or for multibyte digit characters.
Fix the code pattern by using 'width > 0' comparison, and apply the fix
throughout even to code handling integer conversions so as to interpret
the field width consistently and avoid people's confusion even if width
cannot be 0 at those places.
For multibyte digit characters there is an additional issue that causes
code to push back a partially fetched multibyte character multiple times
as execution proceeds through matching data retrieved against individual
digits that have to be rejected due to the field width limit preventing
the rest of the multibyte character from being retrieved. It is because
code relies on 'ungetc' ignoring a request to push back EOF, however in
the out-of-limit field width condition the data held is not EOF but the
previously retrieved character byte instead.
Fix this issue by artificially assigning EOF to the character byte
storage variable where the out-of-limit field width condition prevents
further processing, and also apply the fix throughout except for the
decimal point/thousands separator case, which uses different code.
Add test cases accordingly.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/unix/sysv/linux/syslog.c')
0 files changed, 0 insertions, 0 deletions