From: Collin Funk Date: Fri, 10 Oct 2025 03:40:05 +0000 (-0700) Subject: getdelim tests: Add a test for the glibc bug. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2632ca0dee12a073ce4b0e70a290100d1e4cb8b;p=thirdparty%2Fgnulib.git getdelim tests: Add a test for the glibc bug. * tests/test-getdelim.c (main): Check that the buffer is terminated with a NUL character when the first character read is EOF. --- diff --git a/ChangeLog b/ChangeLog index bb326cdfdf..7e14807d12 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2025-10-10 Collin Funk + getdelim tests: Add a test for the glibc bug. + * tests/test-getdelim.c (main): Check that the buffer is terminated with + a NUL character when the first character read is EOF. + getdelim: Work around a glibc bug. * m4/getdelim.m4 (gl_FUNC_GETDELIM): Check that the buffer is terminated with a NUL character when the first character read is EOF. Guess that diff --git a/tests/test-getdelim.c b/tests/test-getdelim.c index b7911464e3..3696d0f5ab 100644 --- a/tests/test-getdelim.c +++ b/tests/test-getdelim.c @@ -84,7 +84,11 @@ main (void) ASSERT (memcmp (line, "d\0f", 4) == 0); ASSERT (3 < len); + /* Test that reading an EOF will terminate the buffer with a NUL + character. */ result = getdelim (&line, &len, 'n', f); + ASSERT (0 < len); + ASSERT (line[0] == '\0'); ASSERT (result == -1); free (line);