]> git.sur5r.net Git - openldap/commitdiff
fix ITS#5286 (NULL + set = NULL); add more verbose set logging if requested
authorPierangelo Masarati <ando@openldap.org>
Thu, 27 Dec 2007 20:27:51 +0000 (20:27 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 27 Dec 2007 20:27:51 +0000 (20:27 +0000)
servers/slapd/sets.c

index 1d9c38d477b85c6c6e47c8d9a422fda2e67ac917..372454ab35de9d028fa7afd1f01117a937d3b3f1 100644 (file)
@@ -151,16 +151,19 @@ slap_set_join(
                                                        sizeof( struct berval ),
                                                        cp->set_op->o_tmpmemctx );
                                        BER_BVZERO( &set[ 0 ] );
-                                       return set;
+                                       goto done2;
                                }
-                               return set_dup( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
+                               set = set_dup( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
+                               goto done2;
                        }
                        slap_set_dispose( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
-                       return set_dup( cp, rset, SLAP_SET_RREF2REF( op_flags ) );
+                       set = set_dup( cp, rset, SLAP_SET_RREF2REF( op_flags ) );
+                       goto done2;
                }
                if ( rset == NULL || BER_BVISNULL( &rset[ 0 ] ) ) {
                        slap_set_dispose( cp, rset, SLAP_SET_RREF2REF( op_flags ) );
-                       return set_dup( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
+                       set = set_dup( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
+                       goto done2;
                }
 
                /* worst scenario: no duplicates */
@@ -277,25 +280,13 @@ slap_set_join(
                j = slap_set_size( lset );
 
                /* handle empty set cases */
-               if ( i == 0 ) {
-                       if ( j == 0 ) {
-                               set = cp->set_op->o_tmpcalloc( i * j + 1, sizeof( struct berval ),
-                                               cp->set_op->o_tmpmemctx );
-                               if ( set == NULL ) {
-                                       break;
-                               }
-                               BER_BVZERO( &set[ 0 ] );
-                               break;
-
-                       } else {
-                               set = set_dup( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
-                               lset = NULL;
+               if ( i == 0 || j == 0 ) {
+                       set = cp->set_op->o_tmpcalloc( 1, sizeof( struct berval ),
+                                       cp->set_op->o_tmpmemctx );
+                       if ( set == NULL ) {
                                break;
                        }
-
-               } else if ( j == 0 ) {
-                       set = set_dup( cp, rset, SLAP_SET_RREF2REF( op_flags ) );
-                       rset = NULL;
+                       BER_BVZERO( &set[ 0 ] );
                        break;
                }
 
@@ -364,6 +355,18 @@ done:;
        if ( lset ) slap_set_dispose( cp, lset, SLAP_SET_LREF2REF( op_flags ) );
        if ( rset ) slap_set_dispose( cp, rset, SLAP_SET_RREF2REF( op_flags ) );
 
+done2:;
+       if ( LogTest( LDAP_DEBUG_ACL ) ) {
+               if ( BER_BVISNULL( set ) ) {
+                       Debug( LDAP_DEBUG_ACL, "  ACL set: empty\n", 0, 0, 0 );
+
+               } else {
+                       for ( i = 0; !BER_BVISNULL( &set[ i ] ); i++ ) {
+                               Debug( LDAP_DEBUG_ACL, "  ACL set[%d]=%s\n", i, set[i].bv_val, 0 );
+                       }
+               }
+       }
+
        return set;
 }