From fad273c2246d7a8b642a0026829870553ac6b714 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 17 Nov 2004 20:04:18 +0000 Subject: [PATCH] Avoid trashing client memory when socket is greater than FD_SETSIZE --- libraries/libldap/os-ip.c | 9 +++++++++ libraries/libldap/os-local.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index dffda70564..dfa3c65650 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -282,6 +282,15 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, #ifdef HAVE_WINSOCK fd_set efds; #endif + +#ifdef FD_SETSIZE + if ( s >= FD_SETSIZE ) { + rc = AC_SOCKET_ERROR; + tcp_close( s ); + ldap_pvt_set_errno( EMFILE ); + return rc; + } +#endif FD_ZERO(&wfds); FD_SET(s, &wfds ); diff --git a/libraries/libldap/os-local.c b/libraries/libldap/os-local.c index 0c3245412f..ff2b93ed51 100644 --- a/libraries/libldap/os-local.c +++ b/libraries/libldap/os-local.c @@ -247,6 +247,14 @@ sendcred: { fd_set wfds, *z=NULL; +#ifdef FD_SETSIZE + if ( s >= FD_SETSIZE ) { + rc = AC_SOCKET_ERROR; + tcp_close( s ); + ldap_pvt_set_errno( EMFILE ); + return rc; + } +#endif do { FD_ZERO(&wfds); FD_SET(s, &wfds ); -- 2.39.5