X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Ffilterentry.c;h=586db3f9b4ccebdfc79c8d0b26e7d93786e3e867;hb=3d522a0c9fd79b0275a219bde1f4465b181a9318;hp=abc0d0345f03eed265a924cc73aa4c5db33ca1e9;hpb=e8c58b4e7f21caa6c0b6006e3528cbad9b8aed45;p=openldap diff --git a/servers/slapd/filterentry.c b/servers/slapd/filterentry.c index abc0d0345f..586db3f9b4 100644 --- a/servers/slapd/filterentry.c +++ b/servers/slapd/filterentry.c @@ -1,8 +1,27 @@ /* filterentry.c - apply a filter to an entry */ /* $OpenLDAP$ */ -/* - * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved. - * COPYING RESTRICTIONS APPLY, see COPYRIGHT file +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2003 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in the file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ +/* Portions Copyright (c) 1995 Regents of the University of Michigan. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that this notice is preserved and that due credit is given + * to the University of Michigan at Ann Arbor. The name of the University + * may not be used to endorse or promote products derived from this + * software without specific prior written permission. This software + * is provided ``as is'' without express or implied warranty. */ #include "portable.h" @@ -196,6 +215,7 @@ static int test_mra_filter( MatchingRuleAssertion *mra ) { Attribute *a; + void *memctx = op ? op->o_tmpmemctx : NULL; if ( mra->ma_desc ) { /* @@ -214,17 +234,16 @@ static int test_mra_filter( a = attrs_find( a->a_next, mra->ma_desc ) ) { struct berval *bv; -#ifdef SLAP_NVALUES /* If ma_rule is not the same as the attribute's * normal rule, then we can't use the a_nvals. */ - if (mra->ma_rule == a->a_desc->ad_type->sat_equality) + if (mra->ma_rule == a->a_desc->ad_type->sat_equality) { bv = a->a_nvals; - else -#endif + } else { bv = a->a_vals; - for ( ; bv->bv_val != NULL; bv++ ) - { + } + + for ( ; bv->bv_val != NULL; bv++ ) { int ret; int rc; const char *text; @@ -257,15 +276,9 @@ static int test_mra_filter( } /* normalize for equality */ -#ifdef SLAP_NVALUES rc = asserted_value_validate_normalize( a->a_desc, mra->ma_rule, SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, - &mra->ma_value, &value, &text ); -#else - rc = value_validate_normalize( a->a_desc, - SLAP_MR_EQUALITY, - &mra->ma_value, &value, &text ); -#endif + &mra->ma_value, &value, &text, memctx ); if ( rc != LDAP_SUCCESS ) { continue; } @@ -277,11 +290,9 @@ static int test_mra_filter( } /* check match */ -#ifdef SLAP_NVALUES if (mra->ma_rule == a->a_desc->ad_type->sat_equality) bv = a->a_nvals; else -#endif bv = a->a_vals; for ( ; bv->bv_val != NULL; bv++ ) { @@ -304,22 +315,22 @@ static int test_mra_filter( /* check attrs in DN AVAs if required */ if ( mra->ma_dnattrs ) { - LDAPDN *dn = NULL; + LDAPDN dn = NULL; int iRDN, iAVA; int rc; /* parse and pretty the dn */ - rc = dnPrettyDN( NULL, &e->e_name, &dn ); + rc = dnPrettyDN( NULL, &e->e_name, &dn, memctx ); if ( rc != LDAP_SUCCESS ) { return LDAP_INVALID_SYNTAX; } /* for each AVA of each RDN ... */ - for ( iRDN = 0; dn[ 0 ][ iRDN ]; iRDN++ ) { - LDAPRDN *rdn = dn[ 0 ][ iRDN ]; + for ( iRDN = 0; dn[ iRDN ]; iRDN++ ) { + LDAPRDN rdn = dn[ iRDN ]; - for ( iAVA = 0; rdn[ 0 ][ iAVA ]; iAVA++ ) { - LDAPAVA *ava = rdn[ 0 ][ iAVA ]; + for ( iAVA = 0; rdn[ iAVA ]; iAVA++ ) { + LDAPAVA *ava = rdn[ iAVA ]; struct berval *bv = &ava->la_value, value; AttributeDescription *ad = (AttributeDescription *)ava->la_private; int ret; @@ -344,15 +355,10 @@ static int test_mra_filter( } /* normalize for equality */ -#ifdef SLAP_NVALUES rc = asserted_value_validate_normalize( ad, mra->ma_rule, SLAP_MR_EXT|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX, - &mra->ma_value, &value, &text ); -#else - rc = value_validate_normalize( ad, SLAP_MR_EQUALITY, - &mra->ma_value, &value, &text ); -#endif + &mra->ma_value, &value, &text, memctx ); if ( rc != LDAP_SUCCESS ) { continue; } @@ -369,12 +375,12 @@ static int test_mra_filter( bv, &value, &text ); if( rc != LDAP_SUCCESS ) { - ldap_dnfree( dn ); + ldap_dnfree_x( dn, memctx ); return rc; } if ( ret == 0 ) { - ldap_dnfree( dn ); + ldap_dnfree_x( dn, memctx ); return LDAP_COMPARE_TRUE; } } @@ -431,11 +437,7 @@ test_ava_filter( continue; } -#ifdef SLAP_NVALUES for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ ) -#else - for ( bv = a->a_vals; bv->bv_val != NULL; bv++ ) -#endif { int ret; int rc; @@ -472,7 +474,7 @@ test_ava_filter( } if ( ava->aa_desc == slap_schema.si_ad_hasSubordinates - && op->o_bd && op->o_bd->be_has_subordinates ) { + && op && op->o_bd && op->o_bd->be_has_subordinates ) { int hasSubordinates; struct berval hs; @@ -486,12 +488,10 @@ test_ava_filter( } if ( hasSubordinates == LDAP_COMPARE_TRUE ) { - hs.bv_val = "TRUE"; - hs.bv_len = sizeof( "TRUE" ) - 1; + hs = slap_true_bv; } else if ( hasSubordinates == LDAP_COMPARE_FALSE ) { - hs.bv_val = "FALSE"; - hs.bv_len = sizeof( "FALSE" ) - 1; + hs = slap_false_bv; } else { return LDAP_OTHER; @@ -532,7 +532,7 @@ test_presence_filter( * is boolean-valued; I think we may live with this * simplification by now */ - if ( op->o_bd && op->o_bd->be_has_subordinates ) { + if ( op && op->o_bd && op->o_bd->be_has_subordinates ) { return LDAP_COMPARE_TRUE; } @@ -659,11 +659,7 @@ test_substrings_filter( continue; } -#ifdef SLAP_NVALUES for ( bv = a->a_nvals; bv->bv_val != NULL; bv++ ) -#else - for ( bv = a->a_vals; bv->bv_val != NULL; bv++ ) -#endif { int ret; int rc;