summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-10-06 13:58:19 +0200
committerGitHub <noreply@github.com>2017-10-06 13:58:19 +0200
commitec76cc486058f36d878eca7511aaa9f764bf1b83 (patch)
treef9974194ddf5c5f94584d5f34c2583d4cad9b7be
parentc7c5f2c4ecc727ac555f51bd20353f7f3ae9c07a (diff)
parent9fe70c9e46fabae11ed7df8e9f97d3136802ba13 (diff)
downloadlibgit2-ec76cc486058f36d878eca7511aaa9f764bf1b83.tar.gz
Merge pull request #4364 from andoma/master
Use SOCK_CLOEXEC when creating sockets
-rw-r--r--src/posix.h3
-rw-r--r--src/socket_stream.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/posix.h b/src/posix.h
index 3e3bcb287..2934f2479 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -60,6 +60,9 @@
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
+#ifndef SOCK_CLOEXEC
+#define SOCK_CLOEXEC 0
+#endif
/* access() mode parameter #defines */
#ifndef F_OK
diff --git a/src/socket_stream.c b/src/socket_stream.c
index 4c795e462..3c2a07c02 100644
--- a/src/socket_stream.c
+++ b/src/socket_stream.c
@@ -104,7 +104,7 @@ int socket_connect(git_stream *stream)
}
for (p = info; p != NULL; p = p->ai_next) {
- s = socket(p->ai_family, p->ai_socktype, p->ai_protocol);
+ s = socket(p->ai_family, p->ai_socktype | SOCK_CLOEXEC, p->ai_protocol);
if (s == INVALID_SOCKET)
continue;