]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/dnssrv.c
silence warnings
[openldap] / libraries / libldap / dnssrv.c
index 1bf7eb64269c0d2071f204d3ea7ddcc6e96c025f..f43d4f4b0d6af3ef16257284dcab330beb694a10 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -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;
        }
     }