From c947cfd66a6bc493106a080bd0fd40d118fbe606 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 24 Aug 2005 01:34:49 +0000 Subject: [PATCH] Fix uninit'd var, check for single-valued attrs --- servers/slapd/overlays/valsort.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/servers/slapd/overlays/valsort.c b/servers/slapd/overlays/valsort.c index 3d064e03e6..c5a14ffad5 100644 --- a/servers/slapd/overlays/valsort.c +++ b/servers/slapd/overlays/valsort.c @@ -87,7 +87,7 @@ valsort_cf_func(ConfigArgs *c) { valsort_info vitmp, *vi; const char *text = NULL; int i; - struct berval bv; + struct berval bv = BER_BVNULL; if ( c->op == SLAP_CONFIG_EMIT ) { for ( vi = on->on_bi.bi_private; vi; vi = vi->vi_next ) { @@ -112,12 +112,14 @@ valsort_cf_func(ConfigArgs *c) { *ptr++ = '"'; ptr = lutil_strcopy( ptr, vi->vi_dn.bv_val ); *ptr++ = '"'; - *ptr++ = ' '; if ( vi->vi_sort & VALSORT_WEIGHTED ) { + *ptr++ = ' '; ptr = lutil_strcopy( ptr, bv2.bv_val ); + } + if ( !BER_BVISNULL( &bv )) { *ptr++ = ' '; + strcpy( ptr, bv.bv_val ); } - strcpy( ptr, bv.bv_val ); ber_bvarray_add( &c->rvalue_vals, &bvret ); } i = ( c->rvalue_vals != NULL ) ? 0 : 1; @@ -149,6 +151,13 @@ valsort_cf_func(ConfigArgs *c) { c->log, c->msg, c->argv[1] ); return(1); } + if ( is_at_single_value( vitmp.vi_ad->ad_type )) { + sprintf( c->msg, "<%s> %s is single-valued, ignoring", c->argv[0], + vitmp.vi_ad->ad_cname.bv_val ); + Debug( LDAP_DEBUG_ANY, "%s: %s (%s)!\n", + c->log, c->msg, c->argv[1] ); + return(0); + } ber_str2bv( c->argv[2], 0, 0, &bv ); i = dnNormalize( 0, NULL, NULL, &bv, &vitmp.vi_dn, NULL ); if ( i ) { -- 2.39.5