]> git.sur5r.net Git - openldap/commitdiff
skip host="" and port=0 (ITS#4610)
authorPierangelo Masarati <ando@openldap.org>
Sat, 5 Aug 2006 17:08:40 +0000 (17:08 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 5 Aug 2006 17:08:40 +0000 (17:08 +0000)
libraries/libldap/dnssrv.c

index 3090c66d4dc5c64301811467b760654434e4245a..09e3936cc38544f816a4649ed8946f3aef68c97e 100644 (file)
@@ -275,8 +275,12 @@ int ldap_domain2hostlist(
                /* weight = (p[2] << 8) | p[3]; */
                port = (p[4] << 8) | p[5];
 
-               buflen = strlen(host) + sizeof(":65355 ");
-               hostlist = (char *) LDAP_REALLOC(hostlist, cur + buflen);
+               if ( port == 0 || host[ 0 ] == '\0' ) {
+                   goto add_size;
+               }
+
+               buflen = strlen(host) + STRLENOF(":65355 ");
+               hostlist = (char *) LDAP_REALLOC(hostlist, cur + buflen + 1);
                if (hostlist == NULL) {
                    rc = LDAP_NO_MEMORY;
                    goto out;
@@ -287,6 +291,7 @@ int ldap_domain2hostlist(
                }
                cur += sprintf(&hostlist[cur], "%s:%hd", host, port);
            }
+add_size:;
            p += size;
        }
     }