]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
unlinkat: Use issymlinkat.
authorBruno Haible <bruno@clisp.org>
Thu, 14 Aug 2025 20:31:48 +0000 (22:31 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 14 Aug 2025 22:23:41 +0000 (00:23 +0200)
* lib/unlinkat.c (rpl_unlinkat): Use issymlinkat instead of readlinkat.
* modules/unlinkat (Depends-on): Remove readlinkat. Add issymlinkat.

ChangeLog
lib/unlinkat.c
modules/unlinkat

index 6fcc5d6eae60960105295b9aaf455b00289093c8..7f890698795fbe1adedfe8bca382d867b1ffc3e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-08-14  Bruno Haible  <bruno@clisp.org>
+
+       unlinkat: Use issymlinkat.
+       * lib/unlinkat.c (rpl_unlinkat): Use issymlinkat instead of readlinkat.
+       * modules/unlinkat (Depends-on): Remove readlinkat. Add issymlinkat.
+
 2025-08-14  Bruno Haible  <bruno@clisp.org>
 
        unlink: Use issymlink.
index f2a9d4e93ced69b50f18067c8ab477ba442604bb..847a379a91359434afaf2c5ab09a76ed56000afc 100644 (file)
@@ -71,9 +71,7 @@ rpl_unlinkat (int fd, char const *name, int flag)
           memcpy (short_name, name, len);
           while (len && ISSLASH (short_name[len - 1]))
             short_name[--len] = '\0';
-          char linkbuf[1];
-          if (len && ! (readlinkat (fd, short_name, linkbuf, 1) < 0
-                        && errno == EINVAL))
+          if (len && issymlinkat (fd, short_name) != 0)
             {
               free (short_name);
               errno = EPERM;
index aaacfd936a530c399aeee1ebca08ff0589b5d4d4..24232c431de24cf28b8cdd0b66d04524112c59a8 100644 (file)
@@ -13,6 +13,8 @@ extensions
 fcntl-h         [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]
 openat-h        [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]
 sys_stat-h      [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]
+fstatat         [test $REPLACE_UNLINKAT = 1]
+issymlinkat     [test $REPLACE_UNLINKAT = 1]
 at-internal     [test $HAVE_UNLINKAT = 0]
 errno-h         [test $HAVE_UNLINKAT = 0]
 fchdir          [test $HAVE_UNLINKAT = 0]
@@ -21,8 +23,6 @@ openat-die      [test $HAVE_UNLINKAT = 0]
 rmdir           [test $HAVE_UNLINKAT = 0]
 save-cwd        [test $HAVE_UNLINKAT = 0]
 unlink          [test $HAVE_UNLINKAT = 0]
-fstatat         [test $REPLACE_UNLINKAT = 1]
-readlinkat      [test $REPLACE_UNLINKAT = 1]
 
 configure.ac:
 gl_FUNC_UNLINKAT