ID id;
Entry *e;
Attribute *ref;
- char *matched;
+ char *matched = NULL;
int rmaxsize, nrefs;
char *rbuf, *rcur, *r;
int nentries = 0;
Debug(LDAP_DEBUG_ARGS, "=> ldbm_back_search\n", 0, 0, 0);
- if ( tlimit == 0 && be_isroot( be, op->o_dn ) ) {
+ if ( tlimit == 0 && be_isroot( be, op->o_ndn ) ) {
tlimit = -1; /* allow root to set no limit */
} else {
tlimit = (tlimit > be->be_timelimit || tlimit < 1) ?
be->be_timelimit : tlimit;
stoptime = op->o_time + tlimit;
}
- if ( slimit == 0 && be_isroot( be, op->o_dn ) ) {
+ if ( slimit == 0 && be_isroot( be, op->o_ndn ) ) {
slimit = -1; /* allow root to set no limit */
} else {
slimit = (slimit > be->be_sizelimit || slimit < 1) ?
* the subordinates of the base
*/
+#ifdef SLAPD_ALIAS_DEREF
switch ( deref ) {
case LDAP_DEREF_FINDING:
case LDAP_DEREF_ALWAYS:
- free (realBase);
realBase = derefDN ( be, conn, op, base );
break;
default:
realBase = ch_strdup(base);
}
+#else
+ realBase = ch_strdup(base);
+#endif
- (void) dn_normalize (realBase);
+ (void) dn_normalize_case( realBase );
- Debug( LDAP_DEBUG_TRACE, "using base %s\n",
+ Debug( LDAP_DEBUG_TRACE, "using base \"%s\"\n",
realBase, 0, 0 );
switch ( scope ) {
default:
send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, "",
"Bad scope" );
+ if( realBase != NULL) {
+ free( realBase );
+ }
return( -1 );
}
if ( matched != NULL ) {
free( matched );
}
+ if( realBase != NULL) {
+ free( realBase );
+ }
return( -1 );
}
+ if ( matched != NULL ) {
+ free( matched );
+ }
+
rmaxsize = 0;
nrefs = 0;
rbuf = rcur = NULL;
pthread_mutex_unlock( &op->o_abandonmutex );
idl_free( candidates );
free( rbuf );
+ if( realBase != NULL) {
+ free( realBase );
+ }
return( 0 );
}
pthread_mutex_unlock( &op->o_abandonmutex );
NULL, nentries );
idl_free( candidates );
free( rbuf );
+ if( realBase != NULL) {
+ free( realBase );
+ }
return( 0 );
}
pthread_mutex_unlock( ¤ttime_mutex );
* this for subtree searches, and don't check the filter explicitly
* here since it's only a candidate anyway.
*/
- if ( e->e_dn != NULL &&
- strncasecmp( e->e_dn, "ref=", 4 ) == 0 &&
- (ref = attr_find( e->e_attrs, "ref" )) != NULL &&
- scope == LDAP_SCOPE_SUBTREE )
+ if ( scope == LDAP_SCOPE_SUBTREE &&
+ e->e_ndn != NULL &&
+ strncmp( e->e_ndn, "REF=", 4 ) == 0 &&
+ (ref = attr_find( e->e_attrs, "ref" )) != NULL )
{
int i, len;
scopeok = 1;
if ( scope == LDAP_SCOPE_ONELEVEL ) {
if ( (dn = dn_parent( be, e->e_dn )) != NULL ) {
- (void) dn_normalize( dn );
- scopeok = (dn == realBase) ? 1 : (! strcasecmp( dn, realBase ));
+ (void) dn_normalize_case( dn );
+ scopeok = (dn == realBase)
+ ? 1
+ : (strcmp( dn, realBase ) ? 0 : 1 );
+ free( dn );
} else {
scopeok = (realBase == NULL || *realBase == '\0');
}
- free( dn );
} else if ( scope == LDAP_SCOPE_SUBTREE ) {
- dn = ch_strdup( e->e_dn );
- (void) dn_normalize( dn );
+ dn = ch_strdup( e->e_ndn );
scopeok = dn_issuffix( dn, realBase );
free( dn );
}
nrefs > 0 ? rbuf : NULL, nentries );
idl_free( candidates );
free( rbuf );
+
+ if( realBase != NULL) {
+ free( realBase );
+ }
return( 0 );
}
+#ifdef SLAPD_ALIAS_DEREF
/*
* check and apply aliasing where the dereferencing applies to
* the subordinates of the base
}
break;
}
+#endif
switch ( send_search_entry( be, conn, op, e,
attrs, attrsonly ) ) {
cache_return_entry_r( &li->li_cache, e );
idl_free( candidates );
free( rbuf );
+
+ if( realBase != NULL) {
+ free( realBase );
+ }
return( 0 );
}
}
}
free( rbuf );
+ if( realBase != NULL) {
+ free( realBase );
+ }
+
return( 0 );
}
IDList *idl;
Entry *e;
- Debug(LDAP_DEBUG_TRACE, "base_candidates: base: %s\n", base, 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "base_candidates: base: \"%s\"\n", base, 0, 0);
*err = LDAP_SUCCESS;
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- Entry *e;
+ Entry *e = NULL;
Filter *f;
char buf[20];
IDList *candidates;
- Debug(LDAP_DEBUG_TRACE, "onelevel_candidates: base: %s\n", base, 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "onelevel_candidates: base: \"%s\"\n", base, 0, 0);
*err = LDAP_SUCCESS;
- e = NULL;
+
/* get the base object with reader lock */
if ( base != NULL && *base != '\0' &&
(e = dn2entry_r( be, base, matched )) == NULL )
filter_free( f );
/* free entry and reader lock */
- cache_return_entry_r( &li->li_cache, e );
+ if( e != NULL ) {
+ cache_return_entry_r( &li->li_cache, e );
+ }
return( candidates );
}
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
- Filter *f;
+ Filter *f, **filterarg_ptr;
IDList *candidates;
- Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: %s\n",
- base ? base : "NULL", 0, 0);
+ Debug(LDAP_DEBUG_TRACE, "subtree_candidates: base: \"%s\" %s\n",
+ base ? base : "NULL", lookupbase ? "lookupbase" : "", 0);
/*
* get the base object - unless we already have it (from one-level).
*err = LDAP_SUCCESS;
f = NULL;
if ( lookupbase ) {
+ e = NULL;
+
if ( base != NULL && *base != '\0' &&
(e = dn2entry_r( be, base, matched )) == NULL )
{
/* Patch to use normalized uppercase */
f->f_or->f_avvalue.bv_val = ch_strdup( "REFERRAL" );
f->f_or->f_avvalue.bv_len = strlen( "REFERRAL" );
- f->f_or->f_next = filter;
+ filterarg_ptr = &f->f_or->f_next;
+ *filterarg_ptr = filter;
filter = f;
if ( ! be_issuffix( be, base ) ) {
/* free up just the parts we allocated above */
if ( f != NULL ) {
- f->f_and->f_next = NULL;
+ *filterarg_ptr = NULL;
filter_free( f );
}