mirror of
https://github.com/tmate-io/tmate.git
synced 2026-01-23 10:25:37 +00:00
Don't leak dotfd if fchdir fails. From ettl dot martin78 at gmail dot com.
This commit is contained in:
parent
02a848d77c
commit
dca084e703
1 changed files with 5 additions and 1 deletions
|
|
@ -40,8 +40,12 @@ openat(int fd, const char *path, int flags, ...)
|
|||
dotfd = open(".", O_RDONLY);
|
||||
if (dotfd == -1)
|
||||
return (-1);
|
||||
if (fchdir(fd) != 0)
|
||||
if (fchdir(fd) != 0) {
|
||||
saved_errno = errno;
|
||||
close(dotfd);
|
||||
errno = saved_errno;
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
retval = open(path, flags, mode);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue