* returned or filtered out
* e_flags: array of a_flags
*/
- char *a_flags, **e_flags;
+ char **e_flags = NULL;
if (op->o_callback && op->o_callback->sc_sendentry) {
return op->o_callback->sc_sendentry( be, conn, op, e, attrs,
* to particular value of attribute and equals 1 if value matches
* to ValuesReturnFilter or 0 if not
*/
- for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next ) i++;
- e_flags = ch_malloc ( i * sizeof(a_flags) );
-
- for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
- for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
-
- if( j ) {
- a_flags = ch_calloc ( j, sizeof(char) );
- /* If no ValuesReturnFilter control return everything */
- if ( op->vrFilter == NULL ) {
- memset(a_flags, 1, j);
- }
- } else {
- a_flags = NULL;
+ if ( op->vrFilter != NULL ) {
+ int k = 0;
+ char *a_flags;
+
+ for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
+ }
+ e_flags = ch_calloc ( 1, i * sizeof(char *) + k );
+ a_flags = (char *)(e_flags + i);
+ for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
+ e_flags[i] = a_flags;
+ a_flags += j;
}
- e_flags[i] = a_flags;
- }
- if ( op->vrFilter != NULL ) {
rc = filter_matched_values(be, conn, op, e->e_attrs, &e_flags) ;
-
if ( rc == -1 ) {
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ERR,
#endif
ber_free( ber, 1 );
- /* free e_flags */
- for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
- }
- free( e_flags );
-
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "matched values filtering error",
NULL, NULL );
#endif
ber_free_buf( ber );
- /* free e_flags */
- for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
- }
- free( e_flags );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding description error", NULL, NULL );
goto error_return;
continue;
}
- if ( e_flags[j][i] == 0 ){
+ if ( op->vrFilter && e_flags[j][i] == 0 ){
continue;
}
#endif
ber_free_buf( ber );
- /* free e_flags */
- for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
- }
- free( e_flags );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding values error",
NULL, NULL );
#endif
ber_free_buf( ber );
- /* free e_flags */
- for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
- }
- free( e_flags );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encode end error", NULL, NULL );
goto error_return;
}
/* free e_flags */
- for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
+ if ( e_flags ) {
+ free( e_flags );
+ e_flags = NULL;
}
- free( e_flags );
/* eventually will loop through generated operational attributes */
/* only have subschemaSubentry implemented */
aa = backend_operational( be, conn, op, e, attrs, opattrs );
- for ( a = aa, i=0; a != NULL; a = a->a_next ) i++;
- e_flags = ch_malloc ( i * sizeof(a_flags) );
-
- for ( a = aa, i=0; a != NULL; a = a->a_next, i++ ) {
- for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
+ if ( aa != NULL && op->vrFilter != NULL ) {
+ int k = 0;
+ char *a_flags;
- a_flags = ch_calloc ( j, sizeof(char) );
- /* If no ValuesReturnFilter control return everything */
- if ( op->vrFilter == NULL ){
- memset(a_flags, 1, j);
+ for ( a = aa, i=0; a != NULL; a = a->a_next, i++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ ) k++;
+ }
+ e_flags = ch_calloc ( 1, i * sizeof(char *) + k );
+ a_flags = (char *)(e_flags + i);
+ for ( a = e->e_attrs, i=0; a != NULL; a = a->a_next, i++ ) {
+ for ( j = 0; a->a_vals[j].bv_val != NULL; j++ );
+ e_flags[i] = a_flags;
+ a_flags += j;
}
- e_flags[i] = a_flags;
- }
-
- if ( op->vrFilter != NULL ) {
rc = filter_matched_values(be, conn, op, aa, &e_flags) ;
if ( rc == -1 ) {
#endif
ber_free( ber, 1 );
- /* free e_flags */
- for ( a = aa, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
- }
- free( e_flags );
-
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "matched values filtering error",
NULL, NULL );
ber_free_buf( ber );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding description error", NULL, NULL );
- /* free e_flags */
- for ( a = aa, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
- }
- free( e_flags );
attrs_free( aa );
goto error_return;
continue;
}
- if ( e_flags[j][i] == 0 ){
+ if ( op->vrFilter && e_flags[j][i] == 0 ){
continue;
}
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encoding values error",
NULL, NULL );
- /* free e_flags */
- for ( a = aa, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
- }
- free( e_flags );
attrs_free( aa );
goto error_return;
ber_free_buf( ber );
send_ldap_result( conn, op, LDAP_OTHER,
NULL, "encode end error", NULL, NULL );
- /* free e_flags */
- for ( a = aa, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
- }
- free( e_flags );
attrs_free( aa );
goto error_return;
}
/* free e_flags */
- for ( a = aa, i=0; a != NULL; a = a->a_next, i++ ) {
- free( e_flags[i] );
+ if ( e_flags ) {
+ free( e_flags );
+ e_flags = NULL;
}
- free( e_flags );
attrs_free( aa );
rc = ber_printf( ber, /*{{{*/ "}N}N}" );
rc = 0;
error_return:;
+ if ( e_flags ) free( e_flags );
return( rc );
}