]> Savannah Git Hosting - gnulib.git/commitdiff
getdelim: Work around buggy implementation on macOS 10.13.
authorBruno Haible <bruno@clisp.org>
Mon, 17 Oct 2022 00:44:54 +0000 (02:44 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 1 Jan 2023 09:13:49 +0000 (10:13 +0100)
* doc/posix-functions/getdelim.texi: Mention the macOS bug.
* m4/getdelim.m4 (gl_FUNC_GETDELIM): Let the "checking for working
getdelim function" test answer 'no' on macOS.

ChangeLog
doc/posix-functions/getdelim.texi
m4/getdelim.m4

index d45545f6b92be1c36ae75c9f587b6b463b62b857..ad3a20cf0123d0918d6a0ff32719e40834ad2ecd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-10-16  Bruno Haible  <bruno@clisp.org>
+
+       getdelim: Work around buggy implementation on macOS 10.13.
+       * doc/posix-functions/getdelim.texi: Mention the macOS bug.
+       * m4/getdelim.m4 (gl_FUNC_GETDELIM): Let the "checking for working
+       getdelim function" test answer 'no' on macOS.
+
 2022-09-26  Daiki Ueno  <ueno@gnu.org>
 
        largefile: fix detection of time_t size on mingw32
index b076658574a5f76e0985b71eea6ed20f999045e3..7e1851fac377df1c0cf0d407042a57f0e0eba514 100644 (file)
@@ -12,6 +12,9 @@ Portability problems fixed by Gnulib:
 This function is missing on some platforms:
 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, Solaris 10, mingw, MSVC 14, Android 4.2.
 @item
+This function makes out-of-bounds reads on some platforms:
+macOS 10.13.
+@item
 This function crashes when passed a pointer to a NULL buffer together with a
 pointer to a non-zero buffer size on some platforms:
 FreeBSD 8.0.
index 0b63b55351ed0100057f5e02fceb573df6599190..703c1f876fbd759a9bddd4241e7a8393b9874d91 100644 (file)
@@ -1,4 +1,4 @@
-# getdelim.m4 serial 15
+# getdelim.m4 serial 16
 
 dnl Copyright (C) 2005-2007, 2009-2022 Free Software Foundation, Inc.
 dnl
@@ -11,7 +11,7 @@ AC_PREREQ([2.59])
 AC_DEFUN([gl_FUNC_GETDELIM],
 [
   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
-  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+  AC_REQUIRE([AC_CANONICAL_HOST])
 
   dnl Persuade glibc <stdio.h> to declare getdelim().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
@@ -24,8 +24,18 @@ AC_DEFUN([gl_FUNC_GETDELIM],
     dnl Found it in some library.  Verify that it works.
     AC_CACHE_CHECK([for working getdelim function],
       [gl_cv_func_working_getdelim],
-      [echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
-       AC_RUN_IFELSE([AC_LANG_SOURCE([[
+      [case "$host_os" in
+         darwin*)
+           dnl On macOS 10.13, valgrind detected an out-of-bounds read during
+           dnl the GNU sed test suite:
+           dnl   Invalid read of size 16
+           dnl      at 0x100EE6A05: _platform_memchr$VARIANT$Base (in /usr/lib/system/libsystem_platform.dylib)
+           dnl      by 0x100B7B0BD: getdelim (in /usr/lib/system/libsystem_c.dylib)
+           dnl      by 0x10000B0BE: ck_getdelim (utils.c:254)
+           gl_cv_func_working_getdelim=no ;;
+         *)
+           echo fooNbarN | tr -d '\012' | tr N '\012' > conftest.data
+           AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #    include <stdio.h>
 #    include <stdlib.h>
 #    include <string.h>
@@ -57,26 +67,28 @@ AC_DEFUN([gl_FUNC_GETDELIM],
       return 0;
     }
     ]])],
-         [gl_cv_func_working_getdelim=yes],
-         [gl_cv_func_working_getdelim=no],
-         [dnl We're cross compiling.
-          dnl Guess it works on glibc2 systems and musl systems.
-          AC_EGREP_CPP([Lucky GNU user],
-            [
+             [gl_cv_func_working_getdelim=yes],
+             [gl_cv_func_working_getdelim=no],
+             [dnl We're cross compiling.
+              dnl Guess it works on glibc2 systems and musl systems.
+              AC_EGREP_CPP([Lucky GNU user],
+                [
 #include <features.h>
 #ifdef __GNU_LIBRARY__
  #if (__GLIBC__ >= 2) && !defined __UCLIBC__
   Lucky GNU user
  #endif
 #endif
-            ],
-            [gl_cv_func_working_getdelim="guessing yes"],
-            [case "$host_os" in
-               *-musl*) gl_cv_func_working_getdelim="guessing yes" ;;
-               *)       gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;;
-             esac
-            ])
-         ])
+                ],
+                [gl_cv_func_working_getdelim="guessing yes"],
+                [case "$host_os" in
+                   *-musl*) gl_cv_func_working_getdelim="guessing yes" ;;
+                   *)       gl_cv_func_working_getdelim="$gl_cross_guess_normal" ;;
+                 esac
+                ])
+             ])
+           ;;
+       esac
       ])
     case "$gl_cv_func_working_getdelim" in
       *yes) ;;