From 6442964059b02d0602b0aad71830969da47de4dc Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 17 Oct 2000 20:30:14 +0000 Subject: [PATCH] Handle *lud_host == '\0' (likely should modify parsers and other codes to disallow such) --- libraries/libldap/open.c | 9 +++++++-- libraries/libldap/request.c | 9 +++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libraries/libldap/open.c b/libraries/libldap/open.c index d67326333c..9df35ac888 100644 --- a/libraries/libldap/open.c +++ b/libraries/libldap/open.c @@ -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; diff --git a/libraries/libldap/request.c b/libraries/libldap/request.c index 99d312580c..1def978bf5 100644 --- a/libraries/libldap/request.c +++ b/libraries/libldap/request.c @@ -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; } -- 2.39.5