kludge-fd_set.c 882 B

1234567891011121314151617181920212223242526272829
  1. /* Placed in the public domain. */
  2. /*
  3. * _FORTIFY_SOURCE includes a misguided check for FD_SET(n)/FD_ISSET(b)
  4. * where n > FD_SETSIZE. This breaks OpenSSH and other programs that
  5. * explicitly allocate fd_sets. To avoid this, we wrap FD_SET in a
  6. * function compiled without _FORTIFY_SOURCE.
  7. */
  8. #include "config.h"
  9. #if defined(HAVE_FEATURES_H) && defined(_FORTIFY_SOURCE)
  10. # include <features.h>
  11. # if defined(__GNU_LIBRARY__) && defined(__GLIBC_PREREQ)
  12. # if __GLIBC_PREREQ(2, 15) && (_FORTIFY_SOURCE > 0)
  13. # undef _FORTIFY_SOURCE
  14. # undef __USE_FORTIFY_LEVEL
  15. # include <sys/socket.h>
  16. void kludge_FD_SET(int n, fd_set *set) {
  17. FD_SET(n, set);
  18. }
  19. int kludge_FD_ISSET(int n, fd_set *set) {
  20. return FD_ISSET(n, set);
  21. }
  22. # endif /* __GLIBC_PREREQ(2, 15) && (_FORTIFY_SOURCE > 0) */
  23. # endif /* __GNU_LIBRARY__ && __GLIBC_PREREQ */
  24. #endif /* HAVE_FEATURES_H && _FORTIFY_SOURCE */