Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/rofl0r/proxychains-ng.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrofl0r <rofl0r@users.noreply.github.com>2020-09-21 12:46:38 +0300
committerrofl0r <rofl0r@users.noreply.github.com>2020-09-21 12:46:38 +0300
commite6c47646601a9a7b4551174bd60f0cd00829e8af (patch)
tree6a651df569a262ae688955600fd585065533afbc
parent2ab631918d8c75c6382a2dcf3a321fb956801f8a (diff)
proxy_dns_old: use pipe2 if available, else O_CLOEXEC
make the old code a little less lame
-rw-r--r--src/core.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/core.c b/src/core.c
index 42bd3e9..9dfba49 100644
--- a/src/core.c
+++ b/src/core.c
@@ -756,7 +756,7 @@ struct hostent* proxy_gethostbyname_old(const char *name)
char buff[256];
in_addr_t addr;
pid_t pid;
- int status;
+ int status, ret;
size_t l;
struct hostent* hp;
@@ -775,8 +775,17 @@ struct hostent* proxy_gethostbyname_old(const char *name)
while ((hp=gethostent()))
if (!strcmp(hp->h_name,name))
return hp;
+#ifdef HAVE_PIPE2
+ ret = pipe2(pipe_fd, O_CLOEXEC);
+#else
+ ret = pipe(pipe_fd);
+ if(ret == 0) {
+ fcntl(pipe_fd[0], F_SETFD, FD_CLOEXEC);
+ fcntl(pipe_fd[1], F_SETFD, FD_CLOEXEC);
+ }
+#endif
- if(pipe(pipe_fd))
+ if(ret)
goto err;
pid = fork();
switch(pid) {