/* $OpenLDAP$ */
/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
static char* get_alias_dn(
Entry *e,
int *err,
- char **errmsg );
+ const char **errmsg );
static char* new_superior(
- char *dn,
- char *oldSup,
- char *newSup );
+ const char *dn,
+ const char *oldSup,
+ const char *newSup );
static int dnlist_subordinate(
char** dnlist,
- char *dn );
+ const char *dn );
Entry *deref_internal_r(
Backend* be,
Entry* alias,
- char* dn,
+ const char* dn_in,
int* err,
Entry** matched,
- char** text )
+ const char** text )
{
+ char *dn;
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
Entry *entry;
Entry *sup;
unsigned depth;
char **dnlist;
- assert( ( alias != NULL && dn == NULL ) || ( alias == NULL && dn != NULL ) );
+ assert( ( alias != NULL && dn_in == NULL )
+ || ( alias == NULL && dn_in != NULL ) );
*matched = NULL;
- *err = LDAP_SUCCESS;
+ *err = LDAP_NO_SUCH_OBJECT;
*text = NULL;
if( alias == NULL ) {
- dn = ch_strdup( dn );
+ dn = ch_strdup( dn_in );
entry = dn2entry_r( be, dn, &sup );
} else {
/* check if aliasDN is a subordinate of any DN in our list */
if( dnlist_subordinate( dnlist, aliasDN ) ) {
+ ch_free( aliasDN );
*matched = entry;
entry = NULL;
*err = LDAP_ALIAS_PROBLEM;
/* attempt to dereference alias */
newe = dn2entry_r( be, aliasDN, &sup );
+ ch_free( aliasDN );
if( newe != NULL ) {
free( dn );
dn = ch_strdup( entry->e_ndn );
charray_add( &dnlist, dn );
continue;
-
}
if ( sup != NULL ) {
}
aliasDN = new_superior( dn, sup->e_ndn, supDN );
+ free(supDN);
if( aliasDN == NULL ) {
free(aliasDN);
static char* get_alias_dn(
Entry *e,
int *err,
- char **errmsg )
+ const char **errmsg )
{
+ char *dn;
Attribute *a;
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- static AttributeDescription *aliasedObjectName = NULL;
-#else
- static const char *aliasedObjectName = NULL;
-#endif
+ AttributeDescription *aliasedObjectName = slap_schema.si_ad_aliasedObjectName;
a = attr_find( e->e_attrs, aliasedObjectName );
return NULL;
}
- return a->a_vals[0]->bv_val;
+ dn = ch_strdup( a->a_vals[0]->bv_val );
+
+ if( dn_normalize(dn) == NULL ) {
+ ch_free( dn );
+ *err = LDAP_ALIAS_PROBLEM;
+ *errmsg = "alias aliasedObjectName value is invalid";
+ return NULL;
+ }
+
+ return dn;
}
-char* new_superior(
- char *dn,
- char *oldSup,
- char *newSup )
+static char* new_superior(
+ const char *dn,
+ const char *oldSup,
+ const char *newSup )
{
char *newDN;
size_t dnlen, olen, nlen;
newDN = ch_malloc( dnlen - olen + nlen + 1 );
- memcpy( newDN, dn, dnlen - olen );
- memcpy( &newDN[dnlen - olen], newSup, nlen );
+ AC_MEMCPY( newDN, dn, dnlen - olen );
+ AC_MEMCPY( &newDN[dnlen - olen], newSup, nlen );
newDN[dnlen - olen + nlen] = '\0';
return newDN;
static int dnlist_subordinate(
char** dnlist,
- char *dn )
+ const char *dn )
{
int i;
assert( dnlist );