libroot/unistd: dup3 should return EINVAL if oldFD == newFD.

As per POSIX-2024.

Fixes #19476.
This commit is contained in:
Augustin Cavalier
2025-03-12 22:01:57 -04:00
parent 0d73795fc9
commit d68fa86ee1
+3 -1
View File
@@ -22,12 +22,14 @@ dup(int fd)
int
dup2(int oldFD, int newFD)
{
return dup3(oldFD, newFD, 0);
RETURN_AND_SET_ERRNO(_kern_dup2(oldFD, newFD, 0));
}
int
dup3(int oldFD, int newFD, int flags)
{
if (oldFD == newFD)
RETURN_AND_SET_ERRNO(EINVAL);
RETURN_AND_SET_ERRNO(_kern_dup2(oldFD, newFD, flags));
}