From 256ab7351b67e123f9f12bd0dd8bcf90f7bfd22b Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 8 Jan 2026 18:21:06 -0500 Subject: [PATCH] libroot/posix: fchdir() should not accept AT_FDCWD. It doesn't make sense to change directories to the current one. Should fix #19059. --- src/system/libroot/posix/unistd/directory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/system/libroot/posix/unistd/directory.c b/src/system/libroot/posix/unistd/directory.c index 8934a443a4..3d58ba39db 100644 --- a/src/system/libroot/posix/unistd/directory.c +++ b/src/system/libroot/posix/unistd/directory.c @@ -23,6 +23,8 @@ chdir(const char *path) int fchdir(int fd) { + if (fd < 0) + RETURN_AND_SET_ERRNO(EBADF); RETURN_AND_SET_ERRNO(_kern_setcwd(fd, NULL)); }