Fixed bug in do_search eating up controls.
filter_free( a->acl_filter );
if ( a->acl_dn_pat.bv_len )
free ( a->acl_dn_pat.bv_val );
- for (; a->acl_attrs; a->acl_attrs = an) {
- an = a->acl_attrs->an_next;
- free( a->acl_attrs->an_name.bv_val );
+ if ( a->acl_attrs ) {
+ for ( an = a->acl_attrs; an->an_name.bv_val; an++ ) {
+ free( an->an_name.bv_val );
+ }
free( a->acl_attrs );
}
for (; a->acl_access; a->acl_access = n) {
to++;
fprintf( stderr, " attrs=" );
- for ( an = a->acl_attrs; an; an=an->an_next ) {
+ for ( an = a->acl_attrs; an && an->an_name.bv_val; an++ ) {
if ( ! first ) {
fprintf( stderr, "," );
}
AttributeDescription *desc,
AttributeName *attrs )
{
- for( ; attrs; attrs=attrs->an_next ) {
+ if (! attrs ) return 0;
+
+ for( ; attrs->an_name.bv_val; attrs++ ) {
ObjectClass *oc;
int rc;
{
if( a == NULL ) return 0;
- for ( ; a; a=a->an_next ) {
+ for ( ; a->an_name.bv_val; a++ ) {
if ( a->an_name.bv_len != s->bv_len) continue;
if ( strcasecmp( s->bv_val, a->an_name.bv_val ) == 0 ) {
return( 1 );
char *str;
char *s;
char *lasts;
+ int i, j;
const char *text;
- AttributeName *a, *anew;
+ AttributeName *anew;
+ /* find last element in list */
+ for (i = 0; an && an[i].an_name.bv_val; i++);
+
/* protect the input string from strtok */
str = ch_strdup( in );
- /* find last element in list */
- for (a = an; a && a->an_next; a=a->an_next);
-
+ /* Count words in string */
+ j=1;
+ for ( s = str; *s; s++ ) {
+ if ( strchr( brkstr, *s ) != NULL ) {
+ j++;
+ }
+ }
+
+ an = ch_realloc( an, ( i + j + 1 ) * sizeof( AttributeName ) );
+ anew = an + i;
for ( s = ldap_pvt_strtok( str, brkstr, &lasts );
s != NULL;
s = ldap_pvt_strtok( NULL, brkstr, &lasts ) )
{
- anew = ch_malloc( sizeof( AttributeName ) );
- anew->an_next = NULL;
anew->an_desc = NULL;
ber_str2bv(s, 0, 1, &anew->an_name);
slap_bv2ad(&anew->an_name, &anew->an_desc, &text);
- if (!an) {
- an = anew;
- } else {
- a->an_next = anew;
- }
- a = anew;
+ anew++;
}
+ anew->an_name.bv_val = NULL;
free( str );
return( an );
char **
ldap_back_map_attrs(
struct ldapmap *at_map,
- AttributeName *a,
+ AttributeName *an,
int remap
)
{
int i;
char **na;
- AttributeName *an;
struct berval mapped;
- if (a == NULL)
+ if (an == NULL)
return(NULL);
- for (i = 0, an=a; an; an=an->an_next, i++) {
+ for (i = 0; an[i].an_name.bv_val; i++) {
/* */
}
if (na == NULL)
return(NULL);
- for (i = 0, an=a; an; an=an->an_next) {
- ldap_back_map(at_map, &an->an_name, &mapped, remap);
+ for (i = 0; an[i].an_name.bv_val; i++) {
+ ldap_back_map(at_map, &an[i].an_name, &mapped, remap);
if (mapped.bv_val != NULL) {
na[i] = mapped.bv_val;
i++;
mapped_attrs = ldap_back_map_attrs(&li->at_map, attrs, 0);
if ( mapped_attrs == NULL && attrs) {
- AttributeName *an;
- for (count=0, an=attrs; an; an=an->an_next,count++);
+ for (count=0; attrs[count].an_name.bv_val; count++);
mapped_attrs = ch_malloc( (count+1) * sizeof(char *));
- for (count=0, an=attrs; an; an=an->an_next,count++) {
- mapped_attrs[count] = an->an_name.bv_val;
+ for (count=0; attrs[count].an_name.bv_val; count++) {
+ mapped_attrs[count] = attrs[count].an_name.bv_val;
}
mapped_attrs[count] = NULL;
}
attrs, 0 );
if ( mapped_attrs == NULL && attrs) {
AttributeName *an;
- for ( count=0, an=attrs; an; an=an->an_next, count++ );
+ for ( count=0, an=attrs; an->an_name.bv_val; an++, count++ );
mapped_attrs = ch_malloc( ( count + 1 ) * sizeof(char *));
- for ( count=0, an=attrs; an; an=an->an_next, count++ ) {
+ for ( count=0, an=attrs; an->an_name.bv_val; an++, count++ ) {
mapped_attrs[ count ] = an->an_name.bv_val;
}
mapped_attrs[ count ] = NULL;
fprintf( wfp, "filter: %s\n", filterstr );
fprintf( wfp, "attrsonly: %d\n", attrsonly ? 1 : 0 );
fprintf( wfp, "attrs:%s", attrs == NULL ? " all" : "" );
- for ( an = attrs; an; an=an->an_next ) {
+ for ( an = attrs; an && an->an_name.bv_val; an++ ) {
fprintf( wfp, " %s", an->an_name.bv_val );
}
fprintf( wfp, "\n" );
struct berval nbase = { 0, NULL };
struct berval fstr = { 0, NULL };
Filter *filter = NULL;
- AttributeName an, *al = NULL, *alast, *anew;
+ AttributeName *an;
+ ber_len_t siz, off;
Backend *be;
int rc;
+ int i;
const char *text;
int manageDSAit;
/* attributes */
- if ( ber_scanf( op->o_ber, "{" /*}*/ ) == LBER_ERROR ) {
+ siz = sizeof(AttributeName);
+ off = 0;
+ if ( ber_scanf( op->o_ber, "{w}}", &an, &siz, off ) == LBER_ERROR ) {
send_ldap_disconnect( conn, op,
LDAP_PROTOCOL_ERROR, "decoding attrs error" );
rc = SLAPD_DISCONNECT;
goto return_results;
}
- while ( ber_scanf( op->o_ber, "o", &an.an_name ) != LBER_ERROR) {
- anew = ch_malloc(sizeof(AttributeName));
- anew->an_next = NULL;
- anew->an_name = an.an_name;
- anew->an_desc = NULL;
- slap_bv2ad( &anew->an_name, &anew->an_desc, &text );
- if (!al) {
- al = anew;
- } else {
- alast->an_next = anew;
- }
- alast = anew;
- }
- if ( ber_scanf( op->o_ber, /*{{*/ "}}" ) == LBER_ERROR ) {
- send_ldap_disconnect( conn, op,
- LDAP_PROTOCOL_ERROR, "decoding attrs error" );
- rc = SLAPD_DISCONNECT;
- goto return_results;
+ for ( i=0; i<siz; i++ ) {
+ an[i].an_desc = NULL;
+ slap_bv2ad(&an[i].an_name, &an[i].an_desc, &text);
}
if( (rc = get_ctrls( conn, op, 1 )) != LDAP_SUCCESS ) {
#endif
- if ( al != NULL ) {
- for ( anew = al; anew; anew=anew->an_next ) {
+ if ( siz != 0 ) {
+ for ( i = 0; i<siz; i++ ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ARGS,
- "do_search: %s", anew->an_name.bv_val ));
+ "do_search: %s", an[i].an_name.bv_val ));
#else
- Debug( LDAP_DEBUG_ARGS, " %s", anew->an_name.bv_val, 0, 0 );
+ Debug( LDAP_DEBUG_ARGS, " %s", an[i].an_name.bv_val, 0, 0 );
#endif
}
if( rc == LDAP_COMPARE_TRUE ) {
send_search_entry( NULL, conn, op,
- entry, al, attrsonly, NULL );
+ entry, an, attrsonly, NULL );
}
entry_free( entry );
if ( be->be_search ) {
(*be->be_search)( be, conn, op, &pbase, &nbase,
scope, deref, sizelimit,
- timelimit, filter, &fstr, al, attrsonly );
+ timelimit, filter, &fstr, an, attrsonly );
} else {
send_ldap_result( conn, op, rc = LDAP_UNWILLING_TO_PERFORM,
NULL, "operation not supported within namingContext", NULL, NULL );
if( fstr.bv_val != NULL) free( fstr.bv_val );
if( filter != NULL) filter_free( filter );
- for (; al; al=anew ) {
- anew = al->an_next;
- free(al->an_name.bv_val);
- free(al);
+ for (i = 0; i<siz; i++ ) {
+ free(an[i].an_name.bv_val);
}
+ free(an);
return rc;
}
} AttributeDescription;
typedef struct slap_attr_name {
- struct slap_attr_name *an_next;
struct berval an_name;
AttributeDescription *an_desc;
} AttributeName;