Skip to content
Commit e930b89d authored by Siddhesh Poyarekar's avatar Siddhesh Poyarekar
Browse files

ungetc: Fix uninitialized read when putting into unused streams [BZ #27821]



When ungetc is called on an unused stream, the backup buffer is
allocated without the main get area being present.  This results in
every subsequent ungetc (as the stream remains in the backup area)
checking uninitialized memory in the backup buffer when trying to put a
character back into the stream.

Avoid comparing the input character with buffer contents when in backup
to avoid this uninitialized read.  The uninitialized read is harmless in
this context since the location is promptly overwritten with the input
character, thus fulfilling ungetc functionality.

Also adjust wording in the manual to drop the paragraph that says glibc
cannot do multiple ungetc back to back since with this change, ungetc
can actually do this.

Signed-off-by: default avatarSiddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: default avatarCarlos O'Donell <carlos@redhat.com>
(cherry picked from commit cdf0f88f)
(cherry picked from commit 804d3c8d)
parent a3db6ce7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment