/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 1998-2004 The OpenLDAP Foundation.
+ * Copyright 1998-2011 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
(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,
}
sprintf(request, "_ldap._tcp.%s", domain);
-#ifdef LDAP_R_COMPILE
- ldap_pvt_thread_mutex_lock(&ldap_int_resolv_mutex);
-#endif
+ LDAP_MUTEX_LOCK(&ldap_int_resolv_mutex);
rc = LDAP_UNAVAILABLE;
#ifdef NS_HFIXEDSZ
/* 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;
/* not first time around */
hostlist[cur++] = ' ';
}
- cur += sprintf(&hostlist[cur], "%s:%hd", host, port);
+ cur += sprintf(&hostlist[cur], "%s:%hu", host, port);
}
+add_size:;
p += size;
}
}
*list = hostlist;
out:
-#ifdef LDAP_R_COMPILE
- ldap_pvt_thread_mutex_unlock(&ldap_int_resolv_mutex);
-#endif
+ LDAP_MUTEX_UNLOCK(&ldap_int_resolv_mutex);
if (request != NULL) {
LDAP_FREE(request);