]> git.ipfire.org Git - thirdparty/glibc.git/commit
libio: Add terminating NUL when the first character is EOF in getdelim [BZ #28038]
authorCollin Funk <collin.funk1@gmail.com>
Thu, 9 Oct 2025 03:10:44 +0000 (20:10 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Fri, 10 Oct 2025 00:38:01 +0000 (17:38 -0700)
commit33eff78c8b28adc4963987880e10d96761f2a167
treea3a5078f5465439a58612e67537c05c341005b5a
parent5a83a403d1bb3d23a0af43faf2a8d971eca7fe33
libio: Add terminating NUL when the first character is EOF in getdelim [BZ #28038]

POSIX requires that the buffer used by getdelim/getline add a
terminating NUL whenever an EOF is read.

* libio/iogetdelim.c (__getdelim): Add a NUL byte when the first
__underflow is called.
* libio/tst-getdelim.c (do_test): Add a test case for the bug.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
libio/iogetdelim.c
libio/tst-getdelim.c