mirror of
https://github.com/rofl0r/proxychains-ng.git
synced 2024-12-22 12:18:47 +00:00
proxy_dns_old: use pipe2 if available, else O_CLOEXEC
make the old code a little less lame
This commit is contained in:
parent
2ab631918d
commit
e6c4764660
13
src/core.c
13
src/core.c
@ -756,7 +756,7 @@ struct hostent* proxy_gethostbyname_old(const char *name)
|
|||||||
char buff[256];
|
char buff[256];
|
||||||
in_addr_t addr;
|
in_addr_t addr;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
int status, ret;
|
||||||
size_t l;
|
size_t l;
|
||||||
struct hostent* hp;
|
struct hostent* hp;
|
||||||
|
|
||||||
@ -775,8 +775,17 @@ struct hostent* proxy_gethostbyname_old(const char *name)
|
|||||||
while ((hp=gethostent()))
|
while ((hp=gethostent()))
|
||||||
if (!strcmp(hp->h_name,name))
|
if (!strcmp(hp->h_name,name))
|
||||||
return hp;
|
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;
|
goto err;
|
||||||
pid = fork();
|
pid = fork();
|
||||||
switch(pid) {
|
switch(pid) {
|
||||||
|
Loading…
Reference in New Issue
Block a user