remove unnecessary workaround for fclose() on OpenBSD

proxychains-ng didn't call fclose() in a particular FILE on OpenBSD if a
test in the Makefile noticed that OpenBSD's fclose() called close() on
the underlying fd of the FILE.

The test hasn't worked for 8 years because an OpenBSD commit prevented
the test from overriding the libc close():
https://cvsweb.openbsd.org/src/lib/libc/stdio/fclose.c?rev=1.10&content-type=text/x-cvsweb-markup
>let internal calls resolve directly and not be overridable
For all this time, the workaround wasn't doing anything.

Additionally, behavior equivalent to calling close() on a fd is
mandatory in POSIX:
https://pubs.opengroup.org/onlinepubs/9699919799.2008edition/
>The fclose() function shall perform the equivalent of a close()
>on the file descriptor

And finally, at least NetBSD 9.3 also uses the close() function to do
the same, but there's no workaround, and no reported misbehavior when
running on NetBSD to work around.

Even if the test did work, all the workaround appears to do is leak a
FILE.
pull/537/head
Guilherme Janczak 2023-12-07 04:00:49 +00:00
parent d5cc80ae16
commit 9d6e4c27b7
No known key found for this signature in database
GPG Key ID: 9F1927DAAC7F9DCD
2 changed files with 2 additions and 7 deletions

3
configure vendored
View File

@ -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

View File

@ -560,9 +560,7 @@ inv_host:
}
}
}
#ifndef BROKEN_FCLOSE
fclose(file);
#endif
if(!count) {
fprintf(stderr, "error: no valid proxy found in config\n");
exit(1);