]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-meta/map.c
Fix compare op
[openldap] / servers / slapd / back-meta / map.c
index 45e1358e0a39953935c8e9ec06e503d21e6953ae..9044c1ffc748295776414d8667ca5241f95796a9 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2008 The OpenLDAP Foundation.
+ * Copyright 1998-2009 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -119,6 +119,15 @@ ldap_back_mapping ( struct ldapmap *map, struct berval *s, struct ldapmapping **
 
        assert( m != NULL );
 
+       /* let special attrnames slip through (ITS#5760) */
+       if ( bvmatch( s, slap_bv_no_attrs )
+               || bvmatch( s, slap_bv_all_user_attrs )
+               || bvmatch( s, slap_bv_all_operational_attrs ) )
+       {
+               *m = NULL;
+               return 0;
+       }
+
        if ( remap == BACKLDAP_REMAP ) {
                tree = map->remap;
 
@@ -140,6 +149,7 @@ ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *bv,
        int remap )
 {
        struct ldapmapping *mapping;
+       int drop_missing;
 
        /* map->map may be NULL when mapping is configured,
         * but map->remap can't */
@@ -149,7 +159,7 @@ ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *bv,
        }
 
        BER_BVZERO( bv );
-       ( void )ldap_back_mapping( map, s, &mapping, remap );
+       drop_missing = ldap_back_mapping( map, s, &mapping, remap );
        if ( mapping != NULL ) {
                if ( !BER_BVISNULL( &mapping->dst ) ) {
                        *bv = mapping->dst;
@@ -157,7 +167,7 @@ ldap_back_map ( struct ldapmap *map, struct berval *s, struct berval *bv,
                return;
        }
 
-       if ( !map->drop_missing ) {
+       if ( !drop_missing ) {
                *bv = *s;
        }
 }
@@ -333,7 +343,7 @@ ldap_back_int_filter_map_rewrite(
 
                fstr->bv_len = atmp.bv_len + vtmp.bv_len
                        + ( sizeof("(=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=%s)",
                        atmp.bv_val, vtmp.bv_len ? vtmp.bv_val : "" );
@@ -350,7 +360,7 @@ ldap_back_int_filter_map_rewrite(
 
                fstr->bv_len = atmp.bv_len + vtmp.bv_len
                        + ( sizeof("(>=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s>=%s)",
                        atmp.bv_val, vtmp.bv_len ? vtmp.bv_val : "" );
@@ -367,7 +377,7 @@ ldap_back_int_filter_map_rewrite(
 
                fstr->bv_len = atmp.bv_len + vtmp.bv_len
                        + ( sizeof("(<=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s<=%s)",
                        atmp.bv_val, vtmp.bv_len ? vtmp.bv_val : "" );
@@ -384,7 +394,7 @@ ldap_back_int_filter_map_rewrite(
 
                fstr->bv_len = atmp.bv_len + vtmp.bv_len
                        + ( sizeof("(~=)") - 1 );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s~=%s)",
                        atmp.bv_val, vtmp.bv_len ? vtmp.bv_val : "" );
@@ -402,7 +412,7 @@ ldap_back_int_filter_map_rewrite(
                /* cannot be a DN ... */
 
                fstr->bv_len = atmp.bv_len + ( STRLENOF( "(=*)" ) );
-               fstr->bv_val = malloc( fstr->bv_len + 128 ); /* FIXME: why 128 ? */
+               fstr->bv_val = ch_malloc( fstr->bv_len + 128 ); /* FIXME: why 128 ? */
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
                        atmp.bv_val );
@@ -462,7 +472,7 @@ ldap_back_int_filter_map_rewrite(
                }
 
                fstr->bv_len = atmp.bv_len + ( STRLENOF( "(=*)" ) );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s=*)",
                        atmp.bv_val );
@@ -472,7 +482,7 @@ ldap_back_int_filter_map_rewrite(
        case LDAP_FILTER_OR:
        case LDAP_FILTER_NOT:
                fstr->bv_len = STRLENOF( "(%)" );
-               fstr->bv_val = malloc( fstr->bv_len + 128 );    /* FIXME: why 128? */
+               fstr->bv_val = ch_malloc( fstr->bv_len + 128 ); /* FIXME: why 128? */
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%c)",
                        f->f_choice == LDAP_FILTER_AND ? '&' :
@@ -517,7 +527,7 @@ ldap_back_int_filter_map_rewrite(
                        ( f->f_mr_dnattrs ? STRLENOF( ":dn" ) : 0 ) +
                        ( !BER_BVISEMPTY( &f->f_mr_rule_text ) ? f->f_mr_rule_text.bv_len + 1 : 0 ) +
                        vtmp.bv_len + ( STRLENOF( "(:=)" ) );
-               fstr->bv_val = malloc( fstr->bv_len + 1 );
+               fstr->bv_val = ch_malloc( fstr->bv_len + 1 );
 
                snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s:=%s)",
                        atmp.bv_val,