From 3b47995f0fb5208ae34b2b0c6ddcf6a311a8b067 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 17 Sep 2024 00:52:28 +0200 Subject: [PATCH] faccessat: Correct errno value on AIX. * lib/faccessat.c (rpl_faccessat): Do the trailing-slash workaround also if the original faccessat invocation failed. --- ChangeLog | 6 ++++++ lib/faccessat.c | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 17e1e7d1cd..a61fba9088 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-09-16 Bruno Haible + + faccessat: Correct errno value on AIX. + * lib/faccessat.c (rpl_faccessat): Do the trailing-slash workaround also + if the original faccessat invocation failed. + 2024-09-10 Bruno Haible mbrtoc16: Fix undefined behaviour. diff --git a/lib/faccessat.c b/lib/faccessat.c index 8178ca8632..6eed1b642a 100644 --- a/lib/faccessat.c +++ b/lib/faccessat.c @@ -63,15 +63,17 @@ rpl_faccessat (int fd, char const *file, int mode, int flag) { int result = orig_faccessat (fd, file, mode, flag); - if (result == 0 && file[strlen (file) - 1] == '/') + if (file[strlen (file) - 1] == '/') { struct stat st; - result = fstatat (fd, file, &st, 0); - if (result == 0 && !S_ISDIR (st.st_mode)) + int ret = fstatat (fd, file, &st, 0); + if (ret == 0 && !S_ISDIR (st.st_mode)) { errno = ENOTDIR; return -1; } + if (result == 0) + result = ret; } return result; -- 2.39.5