From: Pierangelo Masarati Date: Fri, 5 Mar 2004 10:53:35 +0000 (+0000) Subject: improve previous commit X-Git-Tag: OPENLDAP_REL_ENG_2_2_BP~369 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8aedfad3bb55e91cc9bcb6720a2130c6034b2599;p=openldap improve previous commit --- diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index 0dee28d71f..40258b0722 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -3253,7 +3253,10 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx ) len += rdnl; } - if ( ( bv->bv_val = LDAP_MALLOCX( len + 2, ctx ) ) == NULL ) { + /* reserve room for trailing '/' in case the DN + * is exactly a domain */ + if ( ( bv->bv_val = LDAP_MALLOCX( len + 1 + 1, ctx ) ) == NULL ) + { rc = LDAP_NO_MEMORY; break; } @@ -3306,6 +3309,8 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx ) } if ( trailing_slash ) { + /* the DN is exactly a domain -- need a trailing + * slash; room was reserved in advance */ bv->bv_val[ len ] = '/'; len++; } @@ -3313,7 +3318,6 @@ int ldap_dn2bv_x( LDAPDN dn, struct berval *bv, unsigned flags, void *ctx ) bv->bv_len = len; bv->bv_val[ bv->bv_len ] = '\0'; - rc = LDAP_SUCCESS; } break;