]> git.sur5r.net Git - openldap/commitdiff
Handle unknown attributes in SLAPI_SEARCH_ATTRS
authorLuke Howard <lukeh@openldap.org>
Fri, 9 Jun 2006 15:54:59 +0000 (15:54 +0000)
committerLuke Howard <lukeh@openldap.org>
Fri, 9 Jun 2006 15:54:59 +0000 (15:54 +0000)
servers/slapd/slapi/slapi_pblock.c
servers/slapd/slapi/slapi_utils.c

index ea6d4edcb2ae8eaee35e99b34cfd04e6264b7f08..d27a32e1c21880c3e99084d4207b475b5692a761 100644 (file)
@@ -1098,7 +1098,7 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
                break;
        case SLAPI_SEARCH_ATTRS: {
                AttributeName *an = NULL;
-               size_t i = 0;
+               size_t i = 0, j = 0;
                char **attrs = (char **)value;
 
                PBLOCK_ASSERT_OP( pb, 0 );
@@ -1122,18 +1122,20 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
                                ;
                }
                if ( i ) {
-                       an = (AttributeName *)pb->pb_op->o_tmpalloc( (i + 1) *
+                       an = (AttributeName *)pb->pb_op->o_tmpcalloc( i + 1,
                                sizeof(AttributeName), pb->pb_op->o_tmpmemctx );
                        for ( i = 0; attrs[i] != NULL; i++ ) {
-                               an[i].an_desc = NULL;
-                               an[i].an_oc = NULL;
-                               an[i].an_oc_exclude = 0;
-                               an[i].an_name.bv_val = attrs[i];
-                               an[i].an_name.bv_len = strlen( attrs[i] );
-                               slap_bv2ad( &an[i].an_name, &an[i].an_desc, &pb->pb_rs->sr_text );
+                               an[j].an_desc = NULL;
+                               an[j].an_oc = NULL;
+                               an[j].an_oc_exclude = 0;
+                               an[j].an_name.bv_val = attrs[i];
+                               an[j].an_name.bv_len = strlen( attrs[i] );
+                               if ( slap_bv2ad( &an[j].an_name, &an[j].an_desc, &pb->pb_rs->sr_text ) == LDAP_SUCCESS ) {
+                                       j++;
+                               }
                        }
-                       an[i].an_name.bv_val = NULL;
-                       an[i].an_name.bv_len = 0;
+                       an[j].an_name.bv_val = NULL;
+                       an[j].an_name.bv_len = 0;
                }       
                pb->pb_op->ors_attrs = an;
                break;
index 6516a68bac82411d2f8c52428d6a2cfbc273621b..73f16c9a50528401d8783228c99dc3b964349b54 100644 (file)
@@ -1377,7 +1377,7 @@ slapi_send_ldap_search_entry(
        }
 
        if ( i ) {
-               an = (AttributeName *) slapi_ch_malloc( (i+1) * sizeof(AttributeName) );
+               an = (AttributeName *) slapi_ch_calloc( i + 1, sizeof(AttributeName) );
                for ( i = 0; attrs[i] != NULL; i++ ) {
                        an[j].an_name.bv_val = attrs[i];
                        an[j].an_name.bv_len = strlen( attrs[i] );