]> git.sur5r.net Git - openldap/commitdiff
improve previous commit
authorPierangelo Masarati <ando@openldap.org>
Fri, 5 Mar 2004 10:53:35 +0000 (10:53 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 5 Mar 2004 10:53:35 +0000 (10:53 +0000)
libraries/libldap/getdn.c

index 0dee28d71f9134f3962030ac9e8413ee99dc2b39..40258b072206d079313b5b9b4ecf39816feb1dba 100644 (file)
@@ -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;