From 8aedfad3bb55e91cc9bcb6720a2130c6034b2599 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 5 Mar 2004 10:53:35 +0000 Subject: [PATCH] improve previous commit --- libraries/libldap/getdn.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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; -- 2.39.5