From: Howard Chu Date: Wed, 17 Nov 2004 20:04:18 +0000 (+0000) Subject: Avoid trashing client memory when socket is greater than FD_SETSIZE X-Git-Tag: OPENLDAP_REL_ENG_2_3_0ALPHA~284 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=fad273c2246d7a8b642a0026829870553ac6b714;p=openldap Avoid trashing client memory when socket is greater than FD_SETSIZE --- 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 );