diff options
Diffstat (limited to 'openbsd-compat/kludge-fd_set.c')
-rw-r--r-- | openbsd-compat/kludge-fd_set.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/openbsd-compat/kludge-fd_set.c b/openbsd-compat/kludge-fd_set.c new file mode 100644 index 000000000..6c2ffb64b --- /dev/null +++ b/openbsd-compat/kludge-fd_set.c | |||
@@ -0,0 +1,28 @@ | |||
1 | /* Placed in the public domain. */ | ||
2 | |||
3 | /* | ||
4 | * _FORTIFY_SOURCE includes a misguided check for FD_SET(n)/FD_ISSET(b) | ||
5 | * where n > FD_SETSIZE. This breaks OpenSSH and other programs that | ||
6 | * explicitly allocate fd_sets. To avoid this, we wrap FD_SET in a | ||
7 | * function compiled without _FORTIFY_SOURCE. | ||
8 | */ | ||
9 | |||
10 | #include "config.h" | ||
11 | |||
12 | #if defined(HAVE_FEATURES_H) && defined(_FORTIFY_SOURCE) | ||
13 | # include <features.h> | ||
14 | # if defined(__GNU_LIBRARY__) && defined(__GLIBC_PREREQ) | ||
15 | # if __GLIBC_PREREQ(2, 15) && (_FORTIFY_SOURCE > 0) | ||
16 | # undef _FORTIFY_SOURCE | ||
17 | # undef __USE_FORTIFY_LEVEL | ||
18 | # include <sys/socket.h> | ||
19 | void kludge_FD_SET(int n, fd_set *set) { | ||
20 | FD_SET(n, set); | ||
21 | } | ||
22 | int kludge_FD_ISSET(int n, fd_set *set) { | ||
23 | return FD_ISSET(n, set); | ||
24 | } | ||
25 | # endif /* __GLIBC_PREREQ(2, 15) && (_FORTIFY_SOURCE > 0) */ | ||
26 | # endif /* __GNU_LIBRARY__ && __GLIBC_PREREQ */ | ||
27 | #endif /* HAVE_FEATURES_H && _FORTIFY_SOURCE */ | ||
28 | |||