From efd3da586dd87799a726f04aa3bb6a5bcc747fb0 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Mon, 1 Oct 2001 17:58:18 +0000 Subject: [PATCH] Added better handling of getaddrinfo errors --- CHANGES | 3 +++ libraries/libldap/os-ip.c | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 025dced24f..fc15067054 100644 --- a/CHANGES +++ b/CHANGES @@ -7,7 +7,10 @@ OpenLDAP 2.0.16 Engineering Fixed slurpd server down reject fix (ITS#1183) Fixed -llber ber_realloc bug (ITS#1346) Removed -lldbm use of Berkeley CDB + Updated slapd/-lldap getaddrinfo error detection + Updated -lldap_r pthread stack size Build environment + Updated ltconfig for MacOS X 10.1 Updated slapd.conf with ACL example Updated pthread detection Adjust test 7 read/write ratio diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index 79bd49af9f..372d22ddfd 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -312,9 +312,15 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb, AC_GAI_STRERROR(err), 0, 0); return -1; } - sai = res; rc = -1; - do { + + for( sai=res; sai != NULL; sai=sai->ai_next) { + if( sai->ai_addr == NULL ) { + osip_debug(ld, "ldap_connect_to_host: getaddrinfo " + "ai_addr is NULL?\n", 0, 0, 0); + continue; + } + /* we assume AF_x and PF_x are equal for all x */ s = ldap_int_socket( ld, sai->ai_family, SOCK_STREAM ); if ( s == AC_SOCKET_INVALID ) { @@ -353,7 +359,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb, break; } ldap_pvt_close_socket(ld, s); - } while ((sai = sai->ai_next) != NULL); + } freeaddrinfo(res); return rc; -- 2.47.2