1276707Sdes/* Placed in the public domain.  */
2276707Sdes
3276707Sdes/*
4276707Sdes * _FORTIFY_SOURCE includes a misguided check for FD_SET(n)/FD_ISSET(b)
5276707Sdes * where n > FD_SETSIZE. This breaks OpenSSH and other programs that
6276707Sdes * explicitly allocate fd_sets. To avoid this, we wrap FD_SET in a
7276707Sdes * function compiled without _FORTIFY_SOURCE.
8276707Sdes */
9276707Sdes
10276707Sdes#include "config.h"
11276707Sdes
12276707Sdes#if defined(HAVE_FEATURES_H) && defined(_FORTIFY_SOURCE)
13276707Sdes# include <features.h>
14276707Sdes# if defined(__GNU_LIBRARY__) && defined(__GLIBC_PREREQ)
15276707Sdes#  if __GLIBC_PREREQ(2, 15) && (_FORTIFY_SOURCE > 0)
16276707Sdes#   undef _FORTIFY_SOURCE
17276707Sdes#   undef __USE_FORTIFY_LEVEL
18276707Sdes#   include <sys/socket.h>
19276707Sdesvoid kludge_FD_SET(int n, fd_set *set) {
20276707Sdes	FD_SET(n, set);
21276707Sdes}
22276707Sdesint kludge_FD_ISSET(int n, fd_set *set) {
23276707Sdes	return FD_ISSET(n, set);
24276707Sdes}
25276707Sdes#  endif /* __GLIBC_PREREQ(2, 15) && (_FORTIFY_SOURCE > 0) */
26276707Sdes# endif /* __GNU_LIBRARY__ && __GLIBC_PREREQ */
27276707Sdes#endif /* HAVE_FEATURES_H && _FORTIFY_SOURCE */
28276707Sdes
29