X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=servers%2Fslapd%2Fad.c;h=4ac9b6a8c042768c66d4632825fa8605ba45d021;hb=0a465343fb6d6d8df9091699885bf352c3b1d4b3;hp=676cf8d86f39d2881600b2d4d7907132c5c8cbf2;hpb=9b1d798ad2ef1f586c0f390ee65988ff5d568418;p=openldap diff --git a/servers/slapd/ad.c b/servers/slapd/ad.c index 676cf8d86f..4ac9b6a8c0 100644 --- a/servers/slapd/ad.c +++ b/servers/slapd/ad.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2005 The OpenLDAP Foundation. + * Copyright 1998-2006 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -177,7 +177,7 @@ int slap_bv2ad( memset( &desc, 0, sizeof( desc ) ); desc.ad_cname = *bv; name = bv->bv_val; - options = strchr( name, ';' ); + options = ber_bvchr( bv, ';' ); if ( options != NULL && (unsigned) ( options - name ) < bv->bv_len ) { /* don't go past the end of the berval! */ desc.ad_cname.bv_len = options - name; @@ -988,8 +988,9 @@ anlist2attrs( AttributeName * anlist ) char **attrs; ObjectClass *oc; - attrs = anlist2charray( anlist, 1 ); - + if ( anlist == NULL ) + return NULL; + for ( i = 0; anlist[i].an_name.bv_val; i++ ) { if ( ( oc = anlist[i].an_oc ) ) { for ( j = 0; oc->soc_required && oc->soc_required[j]; j++ ) ; @@ -1002,6 +1003,8 @@ anlist2attrs( AttributeName * anlist ) if ( i == 0 ) return NULL; + attrs = anlist2charray( anlist, 1 ); + n = i; if ( k ) @@ -1026,9 +1029,8 @@ anlist2attrs( AttributeName * anlist ) i = 0; while ( attrs && attrs[i] ) { if ( *attrs[i] == '@' ) { + ch_free( attrs[i] ); for ( j = i; attrs[j]; j++ ) { - if ( j == i ) - ch_free( attrs[i] ); attrs[j] = attrs[j+1]; } } else { @@ -1040,9 +1042,8 @@ anlist2attrs( AttributeName * anlist ) j = i + 1; while ( attrs && attrs[j] ) { if ( !strcmp( attrs[i], attrs[j] )) { + ch_free( attrs[j] ); for ( k = j; attrs && attrs[k]; k++ ) { - if ( k == j ) - ch_free( attrs[j] ); attrs[k] = attrs[k+1]; } } else { @@ -1176,6 +1177,15 @@ ad_define_option( const char *name, const char *fname, int lineno ) return 0; } +void +ad_unparse_options( BerVarray *res ) +{ + int i; + for ( i = 0; i < option_count; i++ ) { + value_add_one( res, &options[i].name ); + } +} + /* Find the definition of the option name or prefix matching the arguments */ static Attr_option * ad_find_option_definition( const char *opt, int optlen )