]> git.sur5r.net Git - openldap/commitdiff
ITS#2364 fix unterminated AttributeName array
authorHoward Chu <hyc@openldap.org>
Sun, 23 Mar 2003 16:00:20 +0000 (16:00 +0000)
committerHoward Chu <hyc@openldap.org>
Sun, 23 Mar 2003 16:00:20 +0000 (16:00 +0000)
servers/slapd/slapi/slapi_utils.c

index 6c8e47938baca1de89b3b73cd2a587d3d1d5560b..6dc94495a239ff0e18df032cab36209bf8123009 100644 (file)
@@ -1400,7 +1400,7 @@ slapi_send_ldap_search_entry(
        }
 
        if ( i > 0 ) {
-               an = (AttributeName *) ch_malloc( i * sizeof(AttributeName) );
+               an = (AttributeName *) ch_malloc( (i+1) * sizeof(AttributeName) );
                for ( i = 0; attrs[i] != NULL; i++ ) {
                        an[i].an_name.bv_val = ch_strdup( attrs[i] );
                        an[i].an_name.bv_len = strlen( attrs[i] );
@@ -1408,6 +1408,8 @@ slapi_send_ldap_search_entry(
                        if( slap_bv2ad( &an[i].an_name, &an[i].an_desc, &text ) != LDAP_SUCCESS)
                                return -1;
                }
+               an[i].an_name.bv_len = 0;
+               an[i].an_name.bv_val = NULL;
        }
 
        if ( ( rc = slapi_pblock_get( pb, SLAPI_BACKEND, (void *)&be ) != 0 ) ||