aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-03-18 15:44:23 -0400
committerNick Mathewson <nickm@torproject.org>2013-03-18 15:44:23 -0400
commit0b827cbcb11abece686d402170bd58724a77e365 (patch)
treee677c07fade6ad1d67b91af9a0510877281af6a6 /src/common/compat.c
parenteff1cfaaf7bf82aefd16b39922b1297e2f8ce2c9 (diff)
downloadtor-0b827cbcb11abece686d402170bd58724a77e365.tar
tor-0b827cbcb11abece686d402170bd58724a77e365.tar.gz
Fix another case of bug 8206; patch from flupzor
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 25df9a960..4fa9fee42 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1172,10 +1172,22 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
return -errno;
#if defined(FD_CLOEXEC)
- if (SOCKET_OK(fd[0]))
- fcntl(fd[0], F_SETFD, FD_CLOEXEC);
- if (SOCKET_OK(fd[1]))
- fcntl(fd[1], F_SETFD, FD_CLOEXEC);
+ if (SOCKET_OK(fd[0])) {
+ r = fcntl(fd[0], F_SETFD, FD_CLOEXEC);
+ if (r == -1) {
+ close(fd[0]);
+ close(fd[1]);
+ return -errno;
+ }
+ }
+ if (SOCKET_OK(fd[1])) {
+ r = fcntl(fd[1], F_SETFD, FD_CLOEXEC);
+ if (r == -1) {
+ close(fd[0]);
+ close(fd[1]);
+ return -errno;
+ }
+ }
#endif
goto sockets_ok; /* So that sockets_ok will not be unused. */