#include "slap.h"
#include "back-ldap.h"
+#undef ldap_debug /* silence a warning in ldap-int.h */
#include "../../../libraries/libldap/ldap-int.h"
static void ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc,
/* if requested limit higher than hard limit, abort */
if ( !isroot && tlimit > limit->lms_t_hard ) {
/* no hard limit means use soft instead */
- if ( limit->lms_t_hard == 0 ) {
+ if ( limit->lms_t_hard == 0 && tlimit > limit->lms_t_soft ) {
tlimit = limit->lms_t_soft;
/* positive hard limit means abort */
/* if requested limit higher than hard limit, abort */
if ( !isroot && slimit > limit->lms_s_hard ) {
/* no hard limit means use soft instead */
- if ( limit->lms_s_hard == 0 ) {
+ if ( limit->lms_s_hard == 0 && slimit > limit->lms_s_soft ) {
slimit = limit->lms_s_soft;
/* positive hard limit means abort */
#ifdef ENABLE_REWRITE
if ( mfilter.bv_val != filterstr->bv_val ) {
- ldap_memfree( mfilter.bv_val );
+ free( mfilter.bv_val );
}
#endif /* ENABLE_REWRITE */
rc != -1;
rc = ldap_result(lc->ld, LDAP_RES_ANY, 0, &tv, &res))
{
- int ab;
-
/* check for abandon */
- ldap_pvt_thread_mutex_lock( &op->o_abandonmutex );
- ab = op->o_abandon;
- ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
-
- if (ab) {
+ if (op->o_abandon) {
ldap_abandon(lc->ld, msgid);
rc = 0;
goto finish;
free( mmatch );
}
#endif /* ENABLE_REWRITE */
- free(match);
+ LDAP_FREE(match);
}
if ( err ) {
- free( err );
+ LDAP_FREE( err );
}
if ( mapped_attrs ) {
- free( mapped_attrs );
+ ch_free( mapped_attrs );
}
if ( mapped_filter != filterstr->bv_val ) {
- free( mapped_filter );
+ ch_free( mapped_filter );
}
if ( mbase.bv_val != base->bv_val ) {
free( mbase.bv_val );
attr = (Attribute *)ch_malloc( sizeof(Attribute) );
if (attr == NULL)
continue;
+ attr->a_flags = 0;
attr->a_next = 0;
attr->a_desc = NULL;
if (slap_bv2ad(&mapped, &attr->a_desc, &text) != LDAP_SUCCESS) {
for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++, i++ ) {
ldap_back_map(&li->oc_map, bv, &mapped, 1);
if (mapped.bv_val == NULL) {
- free(bv->bv_val);
+ LBER_FREE(bv->bv_val);
bv->bv_val = NULL;
if (--last < 0)
break;
attr->a_vals[last].bv_val = NULL;
i--;
} else if ( mapped.bv_val != bv->bv_val ) {
- free(bv->bv_val);
+ /*
+ * FIXME: after LBER_FREEing
+ * the value is replaced by
+ * ch_alloc'ed memory
+ */
+ LBER_FREE(bv->bv_val);
ber_dupbv( bv, &mapped );
}
}
-#ifdef ENABLE_REWRITE
/*
* It is necessary to try to rewrite attributes with
* dn syntax because they might be used in ACLs as
* members of groups; since ACLs are applied to the
- * rewritten stuff, no dn-based subecj clause could
+ * rewritten stuff, no dn-based subject clause could
* be used at the ldap backend side (see
* http://www.OpenLDAP.org/faq/data/cache/452.html)
* The problem can be overcome by moving the dn-based
SLAPD_DN_SYNTAX ) == 0 ) {
int i;
for ( i = 0, bv = attr->a_vals; bv->bv_val; bv++, i++ ) {
- char *newval;
+ struct berval newval;
+#ifdef ENABLE_REWRITE
switch ( rewrite_session( li->rwinfo,
"searchResult",
bv->bv_val,
- lc->conn, &newval )) {
+ lc->conn,
+ &newval.bv_val )) {
case REWRITE_REGEXEC_OK:
/* left as is */
- if ( newval == NULL ) {
+ if ( newval.bv_val == NULL ) {
break;
}
#ifdef NEW_LOGGING
" attr=%s:"
" \"%s\" -> \"%s\"\n",
attr->a_desc->ad_type->sat_cname.bv_val,
- bv->bv_val, newval ));
+ bv->bv_val,
+ newval.bv_val ));
#else /* !NEW_LOGGING */
Debug( LDAP_DEBUG_ARGS,
"rw> searchResult on attr=%s: \"%s\" -> \"%s\"\n",
attr->a_desc->ad_type->sat_cname.bv_val,
- bv->bv_val, newval );
+ bv->bv_val, newval.bv_val );
#endif /* !NEW_LOGGING */
free( bv->bv_val );
- bv->bv_val = newval;
- bv->bv_len = strlen( newval );
-
+ *bv = newval;
break;
case REWRITE_REGEXEC_UNWILLING:
*/
break;
}
+#else /* !ENABLE_REWRITE */
+ ldap_back_dn_massage( li, bv, &newval, 0, 0 );
+ *bv = newval;
+#endif /* !ENABLE_REWRITE */
}
-#endif /* ENABLE_REWRITE */
}
*attrp = attr;
attr = ent.e_attrs;
ent.e_attrs = attr->a_next;
if (attr->a_vals != &dummy)
- bvarray_free(attr->a_vals);
- free(attr);
+ ber_bvarray_free(attr->a_vals);
+ ch_free(attr);
}
- if ( ent.e_dn && ent.e_dn != bdn.bv_val )
+ if ( ent.e_dn && ( ent.e_dn != bdn.bv_val ) )
free( ent.e_dn );
if ( ent.e_ndn )
free( ent.e_ndn );