]> git.sur5r.net Git - openldap/commitdiff
Rework getaddrinfo/inet_ntop not to segfault with ai_addr is (bogusly) NULL
authorKurt Zeilenga <kurt@openldap.org>
Sat, 29 Sep 2001 06:32:58 +0000 (06:32 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 29 Sep 2001 06:32:58 +0000 (06:32 +0000)
libraries/libldap/os-ip.c

index b2c44c2f07492f2ce1b38b52d8477ac4b07bf97c..7ee6684cd4b46d819cc9a4b6dd68714fb7d02f24 100644 (file)
@@ -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;