Re: [PATCH] fstatat: support NULL if AT_EMPTY_PATH
Paul Eggert <[email protected]>
| Newsgroups | gmane.comp.lib.gnulib.bugs |
|---|---|
| Organization | UCLA Computer Science Department |
| Message-ID | <[email protected]> |
On 2026-06-25 03:27, Bruno Haible wrote: > The reason is that in this test program you pass fd = AT_FDCWD. > However, the crash in musl libc occurs only if fd>=0. Oh! The light dawns. I installed the attached patch to Gnulib and propagated it into GNU m4. The next CI run for m4 should test it. Thanks.
0001-fstatat-port-null-file-support-to-Alpine-3.24.patch
(text/x-patch, 2.7 KB)
From 3096dd735de70c4ba7b1a5210a1c9cde0ed3204d Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Thu, 25 Jun 2026 08:27:36 -0700 Subject: [PATCH] fstatat: port null file support to Alpine 3.24 Problem reported by Bruno Haible in: https://lists.gnu.org/r/bug-gnulib/2026-06/msg00093.html * m4/fstatat.m4 (gl_FUNC_FSTATAT): When checking for support for a null pointer file, check nonnegative directory file descriptors as well as AT_FDCWD. --- ChangeLog | 9 +++++++++ m4/fstatat.m4 | 15 ++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index bf8784efa9..e0328ee95f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2026-06-25 Paul Eggert <[email protected]> + + fstatat: port null file support to Alpine 3.24 + Problem reported by Bruno Haible in: + https://lists.gnu.org/r/bug-gnulib/2026-06/msg00093.html + * m4/fstatat.m4 (gl_FUNC_FSTATAT): When checking for + support for a null pointer file, check nonnegative directory + file descriptors as well as AT_FDCWD. + 2026-06-25 Bruno Haible <[email protected]> manywarnings: Fix for compilers that are named '$host-gcc'. diff --git a/m4/fstatat.m4 b/m4/fstatat.m4 index b706c891a4..34a1638e9b 100644 --- a/m4/fstatat.m4 +++ b/m4/fstatat.m4 @@ -1,5 +1,5 @@ # fstatat.m4 -# serial 7 +# serial 8 dnl Copyright (C) 2004-2026 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -68,7 +68,7 @@ AC_DEFUN([gl_FUNC_FSTATAT], dnl is not present, and it is not worth the trouble to tune this. AS_CASE([$REPLACE_FSTATAT], [0], - [AC_CACHE_CHECK([whether fstatat+AT_EMPTY_PATH allows null file], + [AC_CACHE_CHECK([for no AT_EMPTY_PATH or fstatat with null file], [gl_cv_func_fstatat_null_file], [AC_RUN_IFELSE( [AC_LANG_PROGRAM( @@ -85,9 +85,14 @@ AC_DEFUN([gl_FUNC_FSTATAT], #endif ]], [[struct stat st; - return - (AT_EMPTY_PATH - && fstatat (AT_FDCWD, NULL, &st, AT_EMPTY_PATH) < 0); + if (!AT_EMPTY_PATH) + return 0; /* No need to replace fstatat. */ + if (fstatat (AT_FDCWD, NULL, &st, AT_EMPTY_PATH) < 0) + return 1; + int fd = open (".", O_RDONLY); + if (fd < 0) + return 1; /* Play it safe. */ + return fstatat (fd, NULL, &st, AT_EMPTY_PATH) < 0; ]])], [gl_cv_func_fstatat_null_file=yes], [gl_cv_func_fstatat_null_file=no], -- 2.53.0