]> git.sur5r.net Git - openldap/commitdiff
Partial ITS#3280 fix. ldap:// referrals only.
authorKurt Zeilenga <kurt@openldap.org>
Sat, 28 Aug 2004 03:25:59 +0000 (03:25 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 28 Aug 2004 03:25:59 +0000 (03:25 +0000)
libraries/libldap/request.c

index 1187e28fae3c2c5ab68d9797ec35c5251044fa9b..fec28e0d1cd164227c7fe675bfb94411345ee406 100644 (file)
@@ -447,20 +447,22 @@ find_connection( LDAP *ld, LDAPURLDesc *srv, int any )
  */
 {
        LDAPConn        *lc;
-       LDAPURLDesc     *ls;
+       LDAPURLDesc     *lcu, *lsu;
+       int lcu_port, lsu_port;
 
        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 &&
-                               *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 ) {
+               lcu = lc->lconn_server;
+               lcu_port = lcu->lud_port ? lcu->lud_port : LDAP_PORT;
+               for ( lsu = srv; lsu != NULL; lsu = lsu->lud_next ) {
+                       lsu_port = lsu->lud_port ? lsu->lud_port : LDAP_PORT;
+                       if ( lcu->lud_host != NULL && *lcu->lud_host != '\0'
+                           && lsu->lud_host != NULL && *lsu->lud_host != '\0'
+                               && strcasecmp( lsu->lud_host, lcu->lud_host ) == 0
+                           && lsu_port == lcu_port ) {
                                return lc;
                        }
-                       if ( !any ) {
-                               break;
-                       }
+
+                       if ( !any ) break;
                }
        }