)
{
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 );
}
}
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) {
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;
/*
* 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(
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;