[PATCH] libio: Add terminating NUL when the first character is EOF in getdelim [BZ #28038]
Collin Funk
collin.funk1@gmail.com
Sun Nov 2 20:08:44 GMT 2025
Hi Adhemerval,
Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:
> This change did raise a potential latent issue with ndbkit, although
> we potentially break it when running old version on newer glibc.
> Do you know the behavior of other libcs?
Apologies for the delayed response. The behavior is quite easy to test
with Gnulib. Here is what occurs on Fedora 43 with the old glibc
behavior:
$ gnulib-tool --create-testdir --dir testdir1 getdelim
$ cd testdir1 && ./configure
$ grep -FA4 'working getdelim' config.log
configure:15945: checking for working getdelim function
configure:16018: gcc -o conftest -g -O2 conftest.c >&5
configure:16018: $? = 0
configure:16018: ./conftest
configure:16018: $? = 8
The configure test sets '$? |= 8' on the old behavior (i.e. not
null-terminating on an empty file).
Here is a list of platforms with the old glibc behavior:
1. Fedora 43 (glibc 2.42)
2. AIX 7.1.1 and AIX 7.3.3
3. Alpine 3.19.8 (musl 1.2.4_git20230717)
4. OpenBSD 7.7
Here is a list of platforms with the new behavior:
1. MacOS 12.6
2. Solaris 11
3. FreeBSD 14.3
> I think the change does close a potential UB in this interface, but
> this kind of break signal that we should keep old behavior as compat
> symbol.
>
> I think we might wait Austin clarification until the release to check
> if move old semantic to a compat symbol or if we revert this patch.
>
> In any case, I think we should do it before the next release.
Agreed, certainly before the next release.
Collin
More information about the Libc-alpha
mailing list