From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zimbra.cs.ucla.edu (zimbra.cs.ucla.edu [131.179.128.68]) by sourceware.org (Postfix) with ESMTPS id CAB40385800F for ; Mon, 28 Dec 2020 21:04:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org CAB40385800F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=eggert@cs.ucla.edu Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EDD13160087; Mon, 28 Dec 2020 13:04:02 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id a9s0ZczGstdT; Mon, 28 Dec 2020 13:04:00 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 9AD561600B2; Mon, 28 Dec 2020 13:04:00 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4aD5ZzwQ9Ohp; Mon, 28 Dec 2020 13:04:00 -0800 (PST) Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com [23.243.218.95]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 6210F160087; Mon, 28 Dec 2020 13:04:00 -0800 (PST) To: Adhemerval Zanella Cc: bug-gnulib@gnu.org, libc-alpha@sourceware.org References: <20201224151701.1751008-1-adhemerval.zanella@linaro.org> <20201224151701.1751008-6-adhemerval.zanella@linaro.org> <2bbe633f-97b7-9416-8d6a-e4c934cf23fd@cs.ucla.edu> <414fce85-5ed9-6438-d5a5-c92b308a4052@linaro.org> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: [PATCH 5/5] stdlib: Remove lstat usage from realpath [BZ #24970] Message-ID: <0b3bb88c-72be-ea63-9443-5166f973618e@cs.ucla.edu> Date: Mon, 28 Dec 2020 13:04:00 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <414fce85-5ed9-6438-d5a5-c92b308a4052@linaro.org> Content-Type: multipart/mixed; boundary="------------9504CDF18E6A24C138E97DA6" Content-Language: en-US X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Dec 2020 21:04:06 -0000 This is a multi-part message in MIME format. --------------9504CDF18E6A24C138E97DA6 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 12/28/20 3:42 AM, Adhemerval Zanella wrote: > On 24/12/2020 21:27, Paul Eggert wrote: >> Also, shouldn't we merge the already-existing Gnulib scratch_buffer ch= anges into glibc, along with this new change? >=20 > Which changes are you referring? Checking against bbaba6ce5 I see all > glibc files for scratch_buffer are similar to the gnulib ones. Sorry false alarm. Don't know what I was thinking of. I incorporated almost all the changes suggested by your=20 recently-proposed glibc changes into Gnulib, by installing the attached=20 into Gnulib savannah master. There are still a few minor discrepancies=20 from what you proposed for glibc, and I plan to comment on those=20 discrepancies in reply to your other emails. --------------9504CDF18E6A24C138E97DA6 Content-Type: text/x-patch; charset=UTF-8; name="0001-canonicalize-simplify-via-scratch_buffer_dupfree.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-canonicalize-simplify-via-scratch_buffer_dupfree.patch" =46rom 62c8b7b665b7c4c54d53496407342c5aefc9f8d1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 28 Dec 2020 11:38:58 -0800 Subject: [PATCH 1/3] canonicalize: simplify via scratch_buffer_dupfree * config/srclist.txt: Adjust accordingly. * lib/canonicalize-lgpl.c (realpath_stk): * lib/canonicalize.c (canonicalize_filename_mode_stk): Simplify by using scratch_buffer_dupfree. * lib/malloc/scratch_buffer.h (scratch_buffer_dupfree): New function. * lib/malloc/scratch_buffer_dupfree.c: New file. * modules/scratch_buffer (Files, Depends-on): Add malloc/scratch_buffer_dupfree.c. --- ChangeLog | 12 +++++++++ config/srclist.txt | 3 ++- lib/canonicalize-lgpl.c | 20 ++++---------- lib/canonicalize.c | 9 +++---- lib/malloc/scratch_buffer.h | 16 +++++++++++ lib/malloc/scratch_buffer_dupfree.c | 41 +++++++++++++++++++++++++++++ modules/scratch_buffer | 4 ++- 7 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 lib/malloc/scratch_buffer_dupfree.c diff --git a/ChangeLog b/ChangeLog index 97966b427..0428619c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2020-12-28 Paul Eggert + + canonicalize: simplify via scratch_buffer_dupfree + * config/srclist.txt: Adjust accordingly. + * lib/canonicalize-lgpl.c (realpath_stk): + * lib/canonicalize.c (canonicalize_filename_mode_stk): + Simplify by using scratch_buffer_dupfree. + * lib/malloc/scratch_buffer.h (scratch_buffer_dupfree): New function. + * lib/malloc/scratch_buffer_dupfree.c: New file. + * modules/scratch_buffer (Files, Depends-on): + Add malloc/scratch_buffer_dupfree.c. + 2020-12-27 Paul Eggert =20 regex: remove glibc21.m4 diff --git a/config/srclist.txt b/config/srclist.txt index f33b1353f..3956082c8 100644 --- a/config/srclist.txt +++ b/config/srclist.txt @@ -49,7 +49,8 @@ $GNUORG Copyright/request-assign.future doc/Copyright $GNUORG Copyright/request-assign.program doc/Copyright $GNUORG Copyright/request-disclaim.changes doc/Copyright =20 -$LIBCSRC include/scratch_buffer.h lib/malloc +#$LIBCSRC include/scratch_buffer.h lib/malloc +#$LIBCSRC malloc/scratch_buffer_dupfree.c lib/malloc $LIBCSRC malloc/scratch_buffer_grow.c lib/malloc $LIBCSRC malloc/scratch_buffer_grow_preserve.c lib/malloc $LIBCSRC malloc/scratch_buffer_set_array_size.c lib/malloc diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 68b6fdf6e..7ac5d412d 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -413,24 +413,14 @@ error: error_nomem: scratch_buffer_free (&extra_buffer); scratch_buffer_free (&link_buffer); - if (failed || rname =3D=3D resolved) - scratch_buffer_free (rname_buf); - - if (failed) - return NULL; =20 - if (rname =3D=3D resolved) - return rname; - idx_t rname_size =3D dest - rname; - if (rname =3D=3D rname_on_stack) + if (failed || rname =3D=3D resolved) { - rname =3D malloc (rname_size); - if (rname =3D=3D NULL) - return NULL; - return memcpy (rname, rname_on_stack, rname_size); + scratch_buffer_free (rname_buf); + return failed ? NULL : resolved; } - char *result =3D realloc (rname, rname_size); - return result !=3D NULL ? result : rname; + + return scratch_buffer_dupfree (rname_buf, dest - rname); } =20 /* Return the canonical absolute name of file NAME. A canonical name diff --git a/lib/canonicalize.c b/lib/canonicalize.c index e8b74d855..48a49e412 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -469,11 +469,10 @@ error: return NULL; } =20 - idx_t rname_size =3D dest - rname; - if (rname =3D=3D rname_on_stack) - return xmemdup (rname, rname_size); - char *result =3D realloc (rname, rname_size); - return result !=3D NULL ? result : rname; + char *result =3D scratch_buffer_dupfree (rname_buf, dest - rname); + if (!result) + xalloc_die (); + return result; } =20 /* Return the canonical absolute name of file NAME, while treating diff --git a/lib/malloc/scratch_buffer.h b/lib/malloc/scratch_buffer.h index c39da7862..48d651b41 100644 --- a/lib/malloc/scratch_buffer.h +++ b/lib/malloc/scratch_buffer.h @@ -132,4 +132,20 @@ scratch_buffer_set_array_size (struct scratch_buffer= *buffer, (buffer, nelem, size)); } =20 +/* Return a copy of *BUFFER's first SIZE bytes as a heap-allocated block= , + deallocating *BUFFER if it was heap-allocated. SIZE must be at + most *BUFFER's size. Return NULL (setting errno) on memory + exhaustion. */ +void *__libc_scratch_buffer_dupfree (struct scratch_buffer *buffer, + size_t size); +libc_hidden_proto (__libc_scratch_buffer_dupfree) + +/* Alias for __libc_scratch_dupfree. */ +static __always_inline void * +scratch_buffer_dupfree (struct scratch_buffer *buffer, size_t size) +{ + void *r =3D __libc_scratch_buffer_dupfree (buffer, size); + return __glibc_likely (r !=3D NULL) ? r : NULL; +} + #endif /* _SCRATCH_BUFFER_H */ diff --git a/lib/malloc/scratch_buffer_dupfree.c b/lib/malloc/scratch_buf= fer_dupfree.c new file mode 100644 index 000000000..5561e99b0 --- /dev/null +++ b/lib/malloc/scratch_buffer_dupfree.c @@ -0,0 +1,41 @@ +/* Variable-sized buffer with on-stack default allocation. + Copyright (C) 2020 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC +# include +#endif + +#include +#include + +void * +__libc_scratch_buffer_dupfree (struct scratch_buffer *buffer, size_t siz= e) +{ + void *data =3D buffer->data; + if (data =3D=3D buffer->__space.__c) + { + void *copy =3D malloc (size); + return copy !=3D NULL ? memcpy (copy, data, size) : NULL; + } + else + { + void *copy =3D realloc (data, size); + return copy !=3D NULL ? copy : data; + } +} +libc_hidden_def (__libc_scratch_buffer_dupfree) diff --git a/modules/scratch_buffer b/modules/scratch_buffer index 4f9a72581..7eedae7cc 100644 --- a/modules/scratch_buffer +++ b/modules/scratch_buffer @@ -4,6 +4,7 @@ Variable-sized buffer with on-stack default allocation. Files: lib/scratch_buffer.h lib/malloc/scratch_buffer.h +lib/malloc/scratch_buffer_dupfree.c lib/malloc/scratch_buffer_grow.c lib/malloc/scratch_buffer_grow_preserve.c lib/malloc/scratch_buffer_set_array_size.c @@ -17,7 +18,8 @@ stddef configure.ac: =20 Makefile.am: -lib_SOURCES +=3D malloc/scratch_buffer_grow.c \ +lib_SOURCES +=3D malloc/scratch_buffer_dupfree.c \ + malloc/scratch_buffer_grow.c \ malloc/scratch_buffer_grow_preserve.c \ malloc/scratch_buffer_set_array_size.c =20 --=20 2.27.0 --------------9504CDF18E6A24C138E97DA6 Content-Type: text/x-patch; charset=UTF-8; name="0002-canonicalize-lgpl-accommodate-picky-cpp.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-canonicalize-lgpl-accommodate-picky-cpp.patch" =46rom 7796b1f6235a0328dc411d51d0da45ddda6d575d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 28 Dec 2020 11:58:38 -0800 Subject: [PATCH 2/3] canonicalize-lgpl: accommodate picky cpp * lib/canonicalize-lgpl.c: Use "defined FUNC_REALPATH_WORKS" in case preprocessor is picky. Reported by Adhemerval Zanella in: https://sourceware.org/pipermail/libc-alpha/2020-December/121130.html --- ChangeLog | 5 +++++ lib/canonicalize-lgpl.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0428619c1..9a91eda92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2020-12-28 Paul Eggert =20 + canonicalize-lgpl: accommodate picky cpp + * lib/canonicalize-lgpl.c: Use "defined FUNC_REALPATH_WORKS" in + case preprocessor is picky. Reported by Adhemerval Zanella in: + https://sourceware.org/pipermail/libc-alpha/2020-December/121130.html + canonicalize: simplify via scratch_buffer_dupfree * config/srclist.txt: Adjust accordingly. * lib/canonicalize-lgpl.c (realpath_stk): diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 7ac5d412d..332b5bab4 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -98,7 +98,7 @@ # define FACCESSAT_NEVER_EOVERFLOWS false #endif =20 -#if !FUNC_REALPATH_WORKS || defined _LIBC +#if defined _LIBC || !FUNC_REALPATH_WORKS =20 /* Return true if FILE's existence can be shown, false (setting errno) otherwise. Follow symbolic links. */ --=20 2.27.0 --------------9504CDF18E6A24C138E97DA6 Content-Type: text/x-patch; charset=UTF-8; name="0003-faccessat-revert-recent-EOVERFLOW-change.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-faccessat-revert-recent-EOVERFLOW-change.patch" =46rom 20527b26f5e020ebaa48a8d5daec4cccebf051df Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 28 Dec 2020 12:38:52 -0800 Subject: [PATCH 3/3] faccessat: revert recent EOVERFLOW change MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit I misunderstood the glibc source code. Deduced from Adhemerval Zanella=E2=80=99s proposed glibc patch in: https://sourceware.org/pipermail/libc-alpha/2020-December/121131.html * doc/posix-functions/faccessat.texi: It is not a problem. * lib/canonicalize-lgpl.c, lib/canonicalize.c, lib/faccessat.c: (FACCESSAT_NEVER_OVERFLOWS): Remove. All uses removed. * lib/faccessat.c: Revert to simpler version now that LSTAT_FOLLOWS_SLASHED_SYMLINK must be false. * m4/faccessat.m4 (gl_FUNC_FACCESSAT_EOVERFLOW): Remove. All uses removed. * modules/canonicalize, modules/canonicalize-lgpl (Files): Remove m4/faccessat.m4. --- ChangeLog | 14 +++++++++++++ doc/posix-functions/faccessat.texi | 14 +++---------- lib/canonicalize-lgpl.c | 16 ++------------- lib/canonicalize.c | 10 ++------- lib/faccessat.c | 14 +------------ m4/canonicalize.m4 | 4 +--- m4/faccessat.m4 | 33 +++--------------------------- modules/canonicalize | 1 - modules/canonicalize-lgpl | 1 - 9 files changed, 26 insertions(+), 81 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9a91eda92..1481becc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2020-12-28 Paul Eggert =20 + faccessat: revert recent EOVERFLOW change + I misunderstood the glibc source code. Deduced from + Adhemerval Zanella=E2=80=99s proposed glibc patch in: + https://sourceware.org/pipermail/libc-alpha/2020-December/121131.html + * doc/posix-functions/faccessat.texi: It is not a problem. + * lib/canonicalize-lgpl.c, lib/canonicalize.c, lib/faccessat.c: + (FACCESSAT_NEVER_OVERFLOWS): Remove. All uses removed. + * lib/faccessat.c: Revert to simpler version now that + LSTAT_FOLLOWS_SLASHED_SYMLINK must be false. + * m4/faccessat.m4 (gl_FUNC_FACCESSAT_EOVERFLOW): + Remove. All uses removed. + * modules/canonicalize, modules/canonicalize-lgpl (Files): + Remove m4/faccessat.m4. + canonicalize-lgpl: accommodate picky cpp * lib/canonicalize-lgpl.c: Use "defined FUNC_REALPATH_WORKS" in case preprocessor is picky. Reported by Adhemerval Zanella in: diff --git a/doc/posix-functions/faccessat.texi b/doc/posix-functions/fac= cessat.texi index 07ea8e7bf..5d5165e47 100644 --- a/doc/posix-functions/faccessat.texi +++ b/doc/posix-functions/faccessat.texi @@ -15,12 +15,6 @@ glibc 2.3.6, macOS 10.12, FreeBSD 7.4, NetBSD 6.1.5, O= penBSD 4.9, Minix 3.1.8, A On some platforms, @code{faccessat (dfd, "file/", amode, flag)} succeeds instead of failing when @file{file} is not a directory. macOS 10.13. -@item -On some platforms, @code{faccessat} can incorrectly fail with -@code{EOVERFLOW} when the mode is @code{F_OK}: -GNU/Linux with glibc 2.32, or with Linux kernel 5.7. -@c This bug should be fixed in glibc 2.33 and kernel 5.8. See: -@c https://sourceware.org/bugzilla/show_bug.cgi?id=3D18683 @end itemize =20 Portability problems not fixed by Gnulib: @@ -36,11 +30,9 @@ The replacement does not support the @code{AT_SYMLINK_= NOFOLLOW} flag, which is supported by GNU @code{faccessat}. @item On some platforms, @code{faccessat} can mishandle @code{AT_EACCESS} -after a process starts as root and then becomes non-root, -or can incorrectly fail with @code{EOVERFLOW} when the mode -is not @code{F_OK}: -GNU/Linux with glibc 2.32, or with Linux kernel 5.7. -@c These bugs should be fixed in glibc 2.33 and kernel 5.8. See: +after a process starts as root and then becomes non-root: +GNU/Linux with glibc 2.32. +@c This bug should be fixed in glibc 2.33. See: @c https://sourceware.org/bugzilla/show_bug.cgi?id=3D18683 @end itemize =20 diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c index 332b5bab4..04fe95253 100644 --- a/lib/canonicalize-lgpl.c +++ b/lib/canonicalize-lgpl.c @@ -44,12 +44,6 @@ =20 #ifdef _LIBC # include -# include -# ifdef __ASSUME_FACCESSAT2 -# define FACCESSAT_NEVER_EOVERFLOWS __ASSUME_FACCESSAT2 -# else -# define FACCESSAT_NEVER_EOVERFLOWS true -# endif # define GCC_LINT 1 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) #else @@ -94,9 +88,6 @@ #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT # define DOUBLE_SLASH_IS_DISTINCT_ROOT false #endif -#ifndef FACCESSAT_NEVER_EOVERFLOWS -# define FACCESSAT_NEVER_EOVERFLOWS false -#endif =20 #if defined _LIBC || !FUNC_REALPATH_WORKS =20 @@ -106,14 +97,11 @@ static bool file_accessible (char const *file) { # if defined _LIBC || HAVE_FACCESSAT - int r =3D __faccessat (AT_FDCWD, file, F_OK, AT_EACCESS); + return __faccessat (AT_FDCWD, file, F_OK, AT_EACCESS) =3D=3D 0; # else struct stat st; - int r =3D __stat (file, &st); + return __stat (file, &st) =3D=3D 0 || errno =3D=3D EOVERFLOW; # endif - - return ((!FACCESSAT_NEVER_EOVERFLOWS && r < 0 && errno =3D=3D EOVERFLO= W) - || r =3D=3D 0); } =20 /* True if concatenating END as a suffix to a file name means that the diff --git a/lib/canonicalize.c b/lib/canonicalize.c index 48a49e412..a4d3aab96 100644 --- a/lib/canonicalize.c +++ b/lib/canonicalize.c @@ -46,9 +46,6 @@ #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT # define DOUBLE_SLASH_IS_DISTINCT_ROOT false #endif -#ifndef FACCESSAT_NEVER_EOVERFLOWS -# define FACCESSAT_NEVER_EOVERFLOWS false -#endif =20 #if ISSLASH ('\\') # define SLASHES "/\\" @@ -62,14 +59,11 @@ static bool file_accessible (char const *file) { # if HAVE_FACCESSAT - int r =3D faccessat (AT_FDCWD, file, F_OK, AT_EACCESS); + return faccessat (AT_FDCWD, file, F_OK, AT_EACCESS) =3D=3D 0; # else struct stat st; - int r =3D stat (file, &st); + return stat (file, &st) =3D=3D 0 || errno =3D=3D EOVERFLOW; # endif - - return ((!FACCESSAT_NEVER_EOVERFLOWS && r < 0 && errno =3D=3D EOVERFLO= W) - || r =3D=3D 0); } =20 /* True if concatenating END as a suffix to a file name means that the diff --git a/lib/faccessat.c b/lib/faccessat.c index 330c54a0b..9f6a11bf6 100644 --- a/lib/faccessat.c +++ b/lib/faccessat.c @@ -32,13 +32,6 @@ #include #undef _GL_INCLUDING_UNISTD_H =20 -#ifndef FACCESSAT_NEVER_EOVERFLOWS -# define FACCESSAT_NEVER_EOVERFLOWS 0 -#endif -#ifndef LSTAT_FOLLOWS_SLASHED_SYMLINK -# define LSTAT_FOLLOWS_SLASHED_SYMLINK 0 -#endif - #if HAVE_FACCESSAT static int orig_faccessat (int fd, char const *name, int mode, int flag) @@ -66,12 +59,7 @@ rpl_faccessat (int fd, char const *file, int mode, int= flag) { int result =3D orig_faccessat (fd, file, mode, flag); =20 - if (result !=3D 0) - { - if (!FACCESSAT_NEVER_EOVERFLOWS && mode =3D=3D F_OK && errno =3D=3D= EOVERFLOW) - return 0; - } - else if (!LSTAT_FOLLOWS_SLASHED_SYMLINK && file[strlen (file) - 1] =3D= =3D '/') + if (result =3D=3D 0 && file[strlen (file) - 1] =3D=3D '/') { struct stat st; result =3D fstatat (fd, file, &st, 0); diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index c8da4dfcb..404db4cb6 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -1,4 +1,4 @@ -# canonicalize.m4 serial 34 +# canonicalize.m4 serial 35 =20 dnl Copyright (C) 2003-2007, 2009-2020 Free Software Foundation, Inc. =20 @@ -11,7 +11,6 @@ dnl with or without modifications, as long as this noti= ce is preserved. AC_DEFUN([gl_FUNC_CANONICALIZE_FILENAME_MODE], [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_FUNC_FACCESSAT_EOVERFLOW]) AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) AC_CHECK_FUNCS_ONCE([canonicalize_file_name faccessat]) AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) @@ -58,7 +57,6 @@ AC_DEFUN([gl_CANONICALIZE_LGPL], AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE], [ AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_REQUIRE([gl_FUNC_FACCESSAT_EOVERFLOW]) AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) AC_CHECK_FUNCS_ONCE([canonicalize_file_name faccessat]) =20 diff --git a/m4/faccessat.m4 b/m4/faccessat.m4 index a4ad31a46..b8da51e4c 100644 --- a/m4/faccessat.m4 +++ b/m4/faccessat.m4 @@ -1,4 +1,4 @@ -# serial 9 +# serial 10 # See if we need to provide faccessat replacement. =20 dnl Copyright (C) 2009-2020 Free Software Foundation, Inc. @@ -8,31 +8,6 @@ dnl with or without modifications, as long as this notic= e is preserved. =20 # Written by Eric Blake. =20 -AC_DEFUN([gl_FUNC_FACCESSAT_EOVERFLOW], -[ - AC_CHECK_FUNCS_ONCE([faccessat]) - if test "$ac_cv_func_faccessat" =3D yes; then - AC_CACHE_CHECK([whether faccessat works when stat would EOVERFLOW], - [gl_cv_func_faccessat_never_eoverflows], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([], - [[#ifdef __linux__ - #include - #if (! (KERNEL_VERSION (5, 8, 0) <=3D LINUX_VERSION_CODE = \ - && 2 < (__GLIBC__ + (33 <=3D __GLIBC_MINOR__)))) - #error "faccessat might fail with EOVERFLOW" - #endif - #endif - ]])], - [gl_cv_func_faccessat_never_eoverflows=3Dyes], - [gl_cv_func_faccessat_never_eoverflows=3Dno])]) - if test "$gl_cv_func_faccessat_never_eoverflows" =3D yes; then - AC_DEFINE([FACCESSAT_NEVER_EOVERFLOWS], 1, - [Define to 1 if faccessat is EOVERFLOW-free.]) - fi - fi -]) - AC_DEFUN([gl_FUNC_FACCESSAT], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) @@ -41,14 +16,12 @@ AC_DEFUN([gl_FUNC_FACCESSAT], dnl Persuade glibc to declare faccessat(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) =20 - AC_REQUIRE([gl_FUNC_FACCESSAT_EOVERFLOW]) - AC_CHECK_FUNCS_ONCE([faccessat]) if test $ac_cv_func_faccessat =3D no; then HAVE_FACCESSAT=3D0 else - case $gl_cv_func_lstat_dereferences_slashed_symlink,$gl_cv_func_facc= essat_never_eoverflows in - *yes,*yes) ;; + case $gl_cv_func_lstat_dereferences_slashed_symlink in + *yes) ;; *) REPLACE_FACCESSAT=3D1 ;; esac fi diff --git a/modules/canonicalize b/modules/canonicalize index 29919bcdc..5003f2682 100644 --- a/modules/canonicalize +++ b/modules/canonicalize @@ -5,7 +5,6 @@ Files: lib/canonicalize.h lib/canonicalize.c m4/canonicalize.m4 -m4/faccessat.m4 m4/lstat.m4 =20 Depends-on: diff --git a/modules/canonicalize-lgpl b/modules/canonicalize-lgpl index b5f3e7f69..a96f9011e 100644 --- a/modules/canonicalize-lgpl +++ b/modules/canonicalize-lgpl @@ -5,7 +5,6 @@ Files: lib/canonicalize-lgpl.c m4/canonicalize.m4 m4/double-slash-root.m4 -m4/faccessat.m4 m4/lstat.m4 =20 Depends-on: --=20 2.27.0 --------------9504CDF18E6A24C138E97DA6--