X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fdnssrv.c;h=f43d4f4b0d6af3ef16257284dcab330beb694a10;hb=3a2e98e91c3a8f93e5b37cb7e5a76708194cff77;hp=637cd61299c085752b3c0638d8f5deedd708670e;hpb=1634811465c9cbf37207c59f74703c377a4363e1;p=openldap diff --git a/libraries/libldap/dnssrv.c b/libraries/libldap/dnssrv.c index 637cd61299..f43d4f4b0d 100644 --- a/libraries/libldap/dnssrv.c +++ b/libraries/libldap/dnssrv.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * 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 @@ -69,7 +69,7 @@ int ldap_dn2domain( (ava->la_flags & LDAP_AVA_STRING) && ava->la_value.bv_len && ( ber_bvstrcasecmp( &ava->la_attr, &DC ) == 0 - || ber_bvstrcasecmp( &ava->la_attr, &DCOID ) == 0 ) ) + || ber_bvcmp( &ava->la_attr, &DCOID ) == 0 ) ) { if( domain.bv_len == 0 ) { ndomain = LDAP_REALLOC( domain.bv_val, @@ -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; } }