Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove unnecessary workaround for fclose() on OpenBSD #537

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ check_define __FreeBSD__ && bsd_detected=true
check_define __OpenBSD__ && {
bsd_detected=true
echo "CFLAGS+=-DIS_OPENBSD">>config.mak
check_compile_run 'whether OpenBSDs fclose() (illegally) calls close()' \
'#include <stdio.h>\n#include<stdlib.h>\nint close(int x){exit(0);}int main(){fclose(stdin);return 1;}' && \
OUR_CPPFLAGS="$OUR_CPPFLAGS -DBROKEN_FCLOSE"
}
check_define __sun && check_define __SVR4 && solaris_detected=true
check_define __HAIKU__ && haiku_detected=true
Expand Down
6 changes: 2 additions & 4 deletions src/libproxychains.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ typedef struct {
unsigned int first, last, flags;
} close_range_args_t;

/* If there is some `close` or `close_range` system call before do_init,
/* If there is some `close` or `close_range` system call before do_init,
we buffer it, and actually execute them in do_init. */
static int close_fds[16];
static int close_fds_cnt = 0;
Expand Down Expand Up @@ -560,9 +560,7 @@ static void get_chain_data(proxy_data * pd, unsigned int *proxy_count, chain_typ
}
}
}
#ifndef BROKEN_FCLOSE
fclose(file);
#endif
if(!count) {
fprintf(stderr, "error: no valid proxy found in config\n");
exit(1);
Expand Down Expand Up @@ -639,7 +637,7 @@ HOOKFUNC(int, close_range, unsigned first, unsigned last, int flags) {
int protected_fds[] = {req_pipefd[0], req_pipefd[1], resp_pipefd[0], resp_pipefd[1]};
intsort(protected_fds, 4);
/* We are skipping protected_fds while calling true_close_range()
* If protected_fds cut the range into some sub-ranges, we close sub-ranges BEFORE cut point in the loop.
* If protected_fds cut the range into some sub-ranges, we close sub-ranges BEFORE cut point in the loop.
* [first, cut1-1] , [cut1+1, cut2-1] , [cut2+1, cut3-1]
* Finally, we delete the remaining sub-range, outside the loop. [cut3+1, tail]
*/
Expand Down