From: Pierangelo Masarati Date: Thu, 17 Jan 2002 19:05:21 +0000 (+0000) Subject: first round at eliminating dn_parent ... X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~91 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d70f117b69102814eadc990aa777109b326b5760;p=openldap first round at eliminating dn_parent ... --- diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index e01ccc6dae..2f183cb1b1 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -581,13 +581,10 @@ be_issuffix( ) { int i; - size_t len = strlen(suffix); + struct berval bvsuffix = { strlen( suffix ), suffix }; for ( i = 0; be->be_nsuffix != NULL && be->be_nsuffix[i] != NULL; i++ ) { - if ( len != be->be_nsuffix[i]->bv_len ) { - continue; - } - if ( strcmp( be->be_nsuffix[i]->bv_val, suffix ) == 0 ) { + if ( ber_bvcmp( be->be_nsuffix[i], &bvsuffix ) == 0 ) { return( 1 ); } } diff --git a/servers/slapd/backglue.c b/servers/slapd/backglue.c index 59dc6ecec4..fb85602599 100644 --- a/servers/slapd/backglue.c +++ b/servers/slapd/backglue.c @@ -884,8 +884,11 @@ glue_sub_init( ) gi->nodes * sizeof(gluenode)); } gi->n[gi->nodes].be = be; - gi->n[gi->nodes].pdn = dn_parent(NULL, - be->be_nsuffix[0]->bv_val); + if ( dnParent( be->be_nsuffix[0]->bv_val, + (const char **)&gi->n[gi->nodes].pdn ) + != LDAP_SUCCESS ) { + return -1; + } gi->nodes++; } if (gi) { @@ -893,8 +896,11 @@ glue_sub_init( ) gi = (glueinfo *)ch_realloc(gi, sizeof(glueinfo) + gi->nodes * sizeof(gluenode)); gi->n[gi->nodes].be = gi->be; - gi->n[gi->nodes].pdn = dn_parent(NULL, - b1->be_nsuffix[0]->bv_val); + if ( dnParent( b1->be_nsuffix[0]->bv_val, + (const char **)&gi->n[gi->nodes].pdn ) + != LDAP_SUCCESS ) { + return -1; + } gi->nodes++; b1->be_private = gi; b1->bd_info = bi; diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 19960cebf4..7165ff0530 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -604,6 +604,9 @@ dn_normalize( char *dn ) /* * dnParent - dn's parent, in-place + * + * note: the incoming dn is assumed to be normalized/prettyfied, + * so that escaped rdn/ava separators are in '\'+hexpair form */ int dnParent( @@ -611,27 +614,17 @@ dnParent( const char **pdn ) { const char *p; - int rc; - rc = ldap_str2rdn( dn, NULL, (char **)&p, - LDAP_DN_FORMAT_LDAP | LDAP_DN_SKIP ); - if ( rc != LDAP_SUCCESS ) { - return rc; - } + p = strchr( dn, ',' ); - /* Parent is root */ - if (*p == '\0') { - *pdn = ""; - return LDAP_SUCCESS; + if ( p == NULL ) { + return LDAP_INVALID_DN_SYNTAX; } assert( DN_SEPARATOR( p[ 0 ] ) ); p++; - while ( ASCII_SPACE( p[ 0 ] ) ) { - p++; - } - + assert( ! ASCII_SPACE( p[ 0 ] ) ); *pdn = p; return LDAP_SUCCESS;