From: Kurt Zeilenga Date: Sat, 29 Sep 2001 06:32:58 +0000 (+0000) Subject: Rework getaddrinfo/inet_ntop not to segfault with ai_addr is (bogusly) NULL X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1032 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=712295ef4bcdd07d1a1f9b85e8d1be2b58ceee44;p=openldap Rework getaddrinfo/inet_ntop not to segfault with ai_addr is (bogusly) NULL --- diff --git a/libraries/libldap/os-ip.c b/libraries/libldap/os-ip.c index b2c44c2f07..7ee6684cd4 100644 --- a/libraries/libldap/os-ip.c +++ b/libraries/libldap/os-ip.c @@ -333,9 +333,13 @@ 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 ) { + continue; + } + /* we assume AF_x and PF_x are equal for all x */ s = ldap_int_socket( ld, sai->ai_family, socktype ); if ( s == AC_SOCKET_INVALID ) { @@ -374,7 +378,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;