]> git.sur5r.net Git - openldap/commitdiff
Handle *lud_host == '\0'
authorKurt Zeilenga <kurt@openldap.org>
Tue, 17 Oct 2000 20:30:14 +0000 (20:30 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 17 Oct 2000 20:30:14 +0000 (20:30 +0000)
(likely should modify parsers and other codes to disallow such)

libraries/libldap/open.c
libraries/libldap/request.c

index d67326333cc10e318d8674299428e5f758b024a6..9df35ac8885c5066500130ee374c0aa11f9dfc07 100644 (file)
@@ -252,6 +252,7 @@ ldap_int_open_connection(
        char *sasl_host = NULL;
        int sasl_ssf = 0;
 #endif
+       char *host;
        int port;
        long addr;
 
@@ -262,11 +263,15 @@ ldap_int_open_connection(
                        port = htons( (short) srv->lud_port );
 
                        addr = 0;
-                       if ( srv->lud_host == NULL || *srv->lud_host == 0 )
+                       if ( srv->lud_host == NULL || *srv->lud_host == 0 ) {
+                               host = NULL;
                                addr = htonl( INADDR_LOOPBACK );
+                       } else {
+                               host = srv->lud_host;
+                       }
 
                        rc = ldap_connect_to_host( ld, conn->lconn_sb, 0,
-                               srv->lud_host, addr, port, async );
+                               host, addr, port, async );
 
                        if ( rc == -1 ) return rc;
 
index 99d312580cf69256cb5e0fa92759e6a85d92e321..1def978bf548b57e00dbbedb70a15a51297c1b8f 100644 (file)
@@ -351,10 +351,11 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
        for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
                for ( ls = srv; ls != NULL; ls = ls->lud_next ) {
                        if ( lc->lconn_server->lud_host != NULL &&
-                           ls->lud_host != NULL && strcasecmp(
-                           ls->lud_host, lc->lconn_server->lud_host ) == 0
+                               *lc->lconn_server->lud_host != '\0' &&
+                           ls->lud_host != NULL && *ls->lud_host != '\0' &&
+                               strcasecmp( ls->lud_host, lc->lconn_server->lud_host ) == 0
                            && ls->lud_port == lc->lconn_server->lud_port ) {
-                               return( lc );
+                               return lc;
                        }
                        if ( !any ) {
                                break;
@@ -362,7 +363,7 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
                }
        }
 
-       return( NULL );
+       return NULL;
 }