openat: avoid using wrong fd
authorEric Blake <ebb9@byu.net>
Wed, 7 Oct 2009 12:56:52 +0000 (06:56 -0600)
committerEric Blake <ebb9@byu.net>
Wed, 7 Oct 2009 13:15:08 +0000 (07:15 -0600)
commit100bccc49b23e2674a660653fa8036af3730f564
tree6a66961951c2cbe063afddfc2553a7d2c431f542
parentcb7317d75af2de40fecdd949e3fb11a85b09e10a
openat: avoid using wrong fd

Detected by a Solaris failure on:
int fd = dup (0);
close (fd);
mkdirat (fd, "dir", 0700);
which created "./dir" instead of failing with EBADF.

* lib/openat.c (openat_permissive): Reject user's fd if saving the
working directory chooses same fd.
* lib/at-func.c (AT_FUNC_NAME): Likewise.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
lib/at-func.c
lib/openat.c