diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2015-06-10 15:39:23 +0100 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2015-06-10 15:39:23 +0100 |
commit | dca084e703ce54c500e4af7ddc1e0c2b65d4d403 (patch) | |
tree | d83469fe3157637a02149e9638421e3946d6d38a /compat | |
parent | 02a848d77c7f41acecccd58d7819a562eef7c704 (diff) | |
download | rtmux-dca084e703ce54c500e4af7ddc1e0c2b65d4d403.tar.gz rtmux-dca084e703ce54c500e4af7ddc1e0c2b65d4d403.tar.bz2 rtmux-dca084e703ce54c500e4af7ddc1e0c2b65d4d403.zip |
Don't leak dotfd if fchdir fails. From ettl dot martin78 at gmail dot com.
Diffstat (limited to 'compat')
-rw-r--r-- | compat/openat.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compat/openat.c b/compat/openat.c index 5cd9e551..6b04eedc 100644 --- a/compat/openat.c +++ b/compat/openat.c @@ -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); |