From cefce9c965ddbeba658e3243e84e11dea5a6ae9c Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Thu, 27 Dec 2001 17:17:01 +0000 Subject: [PATCH] dnExtractRDN should take a struct berval DN. --- servers/slapd/back-monitor/conn.c | 2 +- servers/slapd/dn.c | 20 ++++++++++++++++---- servers/slapd/proto-slap.h | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 56ad47960a..a91034d388 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -405,7 +405,7 @@ monitor_subsys_conn_create( /* create exactly the required entry */ - if ( dnExtractRdn( ndn->bv_val, &rdn ) != LDAP_SUCCESS ) { + if ( dnExtractRdn( ndn, &rdn ) != LDAP_SUCCESS ) { return( -1 ); } diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 449808b3d1..95382c8f24 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -605,7 +605,7 @@ dn_parent( int dnExtractRdn( - const char *dn, + struct berval *dn, struct berval **rdn ) { LDAPRDN *tmpRDN; @@ -616,7 +616,11 @@ dnExtractRdn( assert( dn ); assert( rdn ); - rc = ldap_str2rdn( dn, &tmpRDN, &p, LDAP_DN_FORMAT_LDAP ); + if( dn->bv_len == 0 ) { + return LDAP_OTHER; + } + + rc = ldap_str2rdn( dn->bv_val, &tmpRDN, &p, LDAP_DN_FORMAT_LDAP ); if ( rc != LDAP_SUCCESS ) { return rc; } @@ -644,6 +648,7 @@ dn_rdnlen( Backend *be, const char *dn_in ) { + struct berval bv; struct berval *rdn = NULL; int retval = 0; @@ -665,7 +670,10 @@ dn_rdnlen( return 0; } - if ( dnExtractRdn( dn_in, &rdn ) != LDAP_SUCCESS ) { + bv.bv_val = (char *) dn_in; + bv.bv_len = strlen( bv.bv_val ); + + if ( dnExtractRdn( &bv, &rdn ) != LDAP_SUCCESS ) { ber_bvfree( rdn ); return 0; } @@ -683,6 +691,7 @@ char * dn_rdn( Backend *be, const char *dn_in ) { + struct berval bv; struct berval *rdn = NULL; char *retval; @@ -704,7 +713,10 @@ char * dn_rdn( return NULL; } - if ( dnExtractRdn( dn_in, &rdn ) != LDAP_SUCCESS ) { + bv.bv_val = (char *) dn_in; + bv.bv_len = strlen( bv.bv_val ); + + if ( dnExtractRdn( &bv, &rdn ) != LDAP_SUCCESS ) { ber_bvfree( rdn ); return NULL; } diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 15cde0736d..1f9e392408 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -374,7 +374,7 @@ LDAP_SLAPD_F (int) dnIsSuffix LDAP_P(( const struct berval *dn, const struct berval *suffix )); LDAP_SLAPD_F (int) dnExtractRdn LDAP_P(( - const char *dn, struct berval **rdn )); + struct berval *dn, struct berval **rdn )); LDAP_SLAPD_F (int) rdnValidate LDAP_P(( struct berval * rdn )); -- 2.39.5