From: Pierangelo Masarati Date: Wed, 13 Feb 2002 10:05:22 +0000 (+0000) Subject: prepare for ldap_bv2dn() X-Git-Tag: OPENLDAP_REL_ENG_2_1_BP~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=959edd88c0dc0ad558d9ebc423996c7a9d0f8cbc;p=openldap prepare for ldap_bv2dn() --- diff --git a/include/ldap.h b/include/ldap.h index 396e32ad7b..625f8f2c39 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -1203,6 +1203,12 @@ ldap_rdnfree LDAP_P(( LDAPRDN *rdn )); LDAP_F( void ) ldap_dnfree LDAP_P(( LDAPDN *dn )); +LDAP_F( int ) +ldap_bv2dn LDAP_P(( + struct berval *bv, + LDAPDN **dn, + unsigned flags )); + LDAP_F( int ) ldap_str2dn LDAP_P(( LDAP_CONST char *str, diff --git a/libraries/libldap/getdn.c b/libraries/libldap/getdn.c index 945d42d2b2..f3c60465fd 100644 --- a/libraries/libldap/getdn.c +++ b/libraries/libldap/getdn.c @@ -598,6 +598,23 @@ ldap_dnfree( LDAPDN *dn ) #define TMP_AVA_SLOTS 8 #define TMP_RDN_SLOTS 32 +int +ldap_bv2dn( struct berval *bv, LDAPDN **dn, unsigned flags ) +{ + assert( bv ); + assert( dn ); + + /* + * FIXME: ldap_bv2dn() and ldap_str2dn() will be swapped, + * i.e. ldap_str2dn() will become a wrapper for ldap_bv2dn() + */ + if ( bv->bv_len != strlen( bv->bv_val ) ) { + return LDAP_INVALID_DN_SYNTAX; + } + + return ldap_str2dn( bv->bv_val, dn, flags ); +} + int ldap_str2dn( LDAP_CONST char *str, LDAPDN **dn, unsigned flags ) { diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index f871e38ce7..031c6c7fa8 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -116,12 +116,7 @@ dnValidate( return( LDAP_SUCCESS ); } - /* FIXME: str2dn should take a bv and handle this */ - if( strlen( in->bv_val ) != in->bv_len ) { - return LDAP_INVALID_SYNTAX; - } - - rc = ldap_str2dn( in->bv_val, &dn, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2dn( in, &dn, LDAP_DN_FORMAT_LDAP ); /* * Schema-aware validate @@ -354,7 +349,7 @@ dnNormalize2( /* * Go to structural representation */ - rc = ldap_str2dn( val->bv_val, &dn, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -424,13 +419,8 @@ dnPretty2( LDAPDN *dn = NULL; int rc; - /* FIXME: str2dn should take a bv and handle this */ - if( strlen( val->bv_val ) != val->bv_len ) { - return LDAP_INVALID_SYNTAX; - } - /* FIXME: should be liberal in what we accept */ - rc = ldap_str2dn( val->bv_val, &dn, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } @@ -495,7 +485,7 @@ dnPrettyNormal( } /* FIXME: should be liberal in what we accept */ - rc = ldap_str2dn( val->bv_val, &dn, LDAP_DN_FORMAT_LDAP ); + rc = ldap_bv2dn( val, &dn, LDAP_DN_FORMAT_LDAP ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; }