]> git.sur5r.net Git - openldap/commitdiff
Avoid trashing client memory when socket is greater than FD_SETSIZE
authorHoward Chu <hyc@openldap.org>
Wed, 17 Nov 2004 20:04:18 +0000 (20:04 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 17 Nov 2004 20:04:18 +0000 (20:04 +0000)
libraries/libldap/os-ip.c
libraries/libldap/os-local.c

index dffda70564d8b9ed067affdd7cac7c42a0613c18..dfa3c65650c3148eb90a8b8c89812ba4e1f564c0 100644 (file)
@@ -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 );
 
index 0c3245412facc2ea3ca1c6317ab7abf1c23fd962..ff2b93ed5182e1fb279195658938d08750e486e9 100644 (file)
@@ -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 );