From 0f8a066654f0cc7c0fcfabf9a204bcda09063654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20B=C3=A9rat?= Date: Wed, 8 Jan 2025 17:15:39 +0100 Subject: [PATCH] Backport getdelim test coverage improvements Resolves: RHEL-54250 --- glibc-RHEL-54250.patch | 60 ++++++++++++++++++++++++++++++++++++++++++ glibc.spec | 2 ++ 2 files changed, 62 insertions(+) create mode 100644 glibc-RHEL-54250.patch diff --git a/glibc-RHEL-54250.patch b/glibc-RHEL-54250.patch new file mode 100644 index 0000000..712376c --- /dev/null +++ b/glibc-RHEL-54250.patch @@ -0,0 +1,60 @@ +commit 3f54e459a633b4247be91b9d0f68a7e08720b8d8 +Author: Frédéric Bérat +Date: Tue Aug 13 12:01:26 2024 +0200 + + libio/tst-getdelim: Add new test covering NUL as a delimiter + + Add a new test to getdelim to verify that '\0' can be set as a + delimiter. + + Reviewed-by: Florian Weimer + +diff --git a/libio/tst-getdelim.c b/libio/tst-getdelim.c +index 44437326691228be..15e2d873a50df782 100644 +--- a/libio/tst-getdelim.c ++++ b/libio/tst-getdelim.c +@@ -1,4 +1,6 @@ +-/* Check that getdelim sets error indicator on error (BZ #29917) ++/* Test getdelim conforming to POSIX specifications. ++ ++ Note: Most getdelim use cases are covered by stdio-common/tst-getline. + + Copyright (C) 2023 Free Software Foundation, Inc. + This file is part of the GNU C Library. +@@ -18,18 +20,36 @@ + . */ + + #include ++#include + #include + + #include ++#include ++#include + + static int + do_test (void) + { ++ /* Check that getdelim sets error indicator on error (BZ #29917) */ + clearerr (stdin); + TEST_VERIFY (getdelim (0, 0, '\n', stdin) == -1); + TEST_VERIFY (ferror (stdin) != 0); + TEST_VERIFY (errno == EINVAL); + ++ /* Test getdelim with NUL as delimiter */ ++ verbose_printf ("Testing NUL delimiter\n"); ++ char *lineptr = NULL; ++ size_t linelen = 0; ++ char membuf[] = "abc\0d\nef\0"; ++ FILE *memstream = fmemopen (membuf, sizeof (membuf), "r"); ++ TEST_VERIFY_EXIT (memstream != NULL); ++ TEST_VERIFY (getdelim (&lineptr, &linelen, '\0', memstream) != -1); ++ TEST_COMPARE_BLOB (lineptr, 4, "abc\0", 4); ++ TEST_VERIFY (getdelim (&lineptr, &linelen, '\0', memstream) != -1); ++ TEST_COMPARE_BLOB (lineptr, 5, "d\nef\0", 5); ++ fclose (memstream); ++ free (lineptr); ++ + return 0; + } + diff --git a/glibc.spec b/glibc.spec index a0012da..1bee253 100644 --- a/glibc.spec +++ b/glibc.spec @@ -1035,6 +1035,7 @@ Patch727: glibc-RHEL-65356-1.patch Patch728: glibc-RHEL-65356-2.patch Patch729: glibc-RHEL-38225-1.patch Patch730: glibc-RHEL-38225-2.patch +Patch731: glibc-RHEL-54250.patch ############################################################################## # Continued list of core "glibc" package information: @@ -3032,6 +3033,7 @@ update_gconv_modules_cache () - Backport: fix the glibc manual to handle spaces for @deftypefun references. (RHEL-65356) - Backport verbosity patches for glibc math (RHEL-38225) +- Backport getdelim test coverage improvements (RHEL-54250) * Thu Dec 19 2024 DJ Delorie - 2.34-148 - Increase ungetc test coverage, guarantee single char pushback (RHEL-46738)