]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: fix errno values set by readlinkat
authorCorinna Vinschen <corinna@vinschen.de>
Tue, 18 Apr 2023 11:52:50 +0000 (13:52 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 18 Apr 2023 11:53:09 +0000 (13:53 +0200)
commit4b8222983f914a7950987802e73fc069dffc3058
tree3dd757ff281faeefddd59c9edfc8fab652a2d37e
parentf87469dd5bcae461bd9fe4da4ee4958ecf353749
Cygwin: fix errno values set by readlinkat

readlinkat(fd, "", ...) is supposed to return ENOENT per POSIX,
but Cygwin returns EBADF.

At the same time, we have to maintain the special feature of
glibc that readlinkat(fd, "", ...) operates on fd, if fd is pointing
at a symlink opened with O_PATH|O_NOFOLLOW.

And, while fixing that, readlinkat(fd, path, ...) *still* has to set errno
to EBADF, if fd is an invalid descriptor *and* path is a relative path.

This required to change the evaluation order in the helper function
gen_full_path_at.

Last but not least, in case of the aforementioned glibc-like special
handling for symlink descriptors, we have to make sure that errors from
gen_full_path_at are not spilled into that special handling.

Fixes: 6cc05784e16a ("Cygwin: readlinkat: allow pathname to be empty")
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/release/3.4.7
winsup/cygwin/syscalls.cc
This page took 0.028371 seconds and 5 git commands to generate.