From 5fe42e8853873682383ca2fd4a33c2644b8e6597 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 21 Apr 2005 21:05:38 +0000 Subject: [PATCH] either pass normalized values to attr_merge*() or call attr_merge_normalize*() (fixes ITS#3659) --- servers/slapd/back-monitor/backend.c | 13 +++++-------- servers/slapd/back-monitor/conn.c | 18 ++++++++---------- servers/slapd/back-monitor/database.c | 25 +++++++++++++------------ servers/slapd/back-monitor/listener.c | 5 ++--- servers/slapd/back-monitor/log.c | 2 +- servers/slapd/back-monitor/operation.c | 4 ++-- servers/slapd/back-monitor/overlay.c | 7 ++----- servers/slapd/back-monitor/rww.c | 2 +- servers/slapd/back-monitor/sent.c | 2 +- 9 files changed, 35 insertions(+), 43 deletions(-) diff --git a/servers/slapd/back-monitor/backend.c b/servers/slapd/back-monitor/backend.c index b9e6084358..1c083afe87 100644 --- a/servers/slapd/back-monitor/backend.c +++ b/servers/slapd/back-monitor/backend.c @@ -108,9 +108,7 @@ monitor_subsys_backend_init( return( -1 ); } - bv.bv_val = bi->bi_type; - bv.bv_len = strlen( bv.bv_val ); - + ber_str2bv( bi->bi_type, 0, 0, &bv ); attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL ); attr_merge_normalize_one( e_backend, mi->mi_ad_monitoredInfo, @@ -120,9 +118,9 @@ monitor_subsys_backend_init( int j; for ( j = 0; bi->bi_controls[ j ]; j++ ) { - bv.bv_val = bi->bi_controls[ j ]; - bv.bv_len = strlen( bv.bv_val ); - attr_merge_one( e, slap_schema.si_ad_supportedControl, &bv, NULL ); + ber_str2bv( bi->bi_controls[ j ], 0, 0, &bv ); + attr_merge_one( e, slap_schema.si_ad_supportedControl, + &bv, &bv ); } } @@ -139,9 +137,8 @@ monitor_subsys_backend_init( snprintf( buf, sizeof( buf ), "cn=Database %d,%s", j, ms_database->mss_dn.bv_val ); - dn.bv_val = buf; - dn.bv_len = strlen( buf ); + ber_str2bv( buf, 0, 0, &dn ); attr_merge_normalize_one( e, mi->mi_ad_seeAlso, &dn, NULL ); } diff --git a/servers/slapd/back-monitor/conn.c b/servers/slapd/back-monitor/conn.c index 40d0a58b91..549c72c880 100644 --- a/servers/slapd/back-monitor/conn.c +++ b/servers/slapd/back-monitor/conn.c @@ -86,7 +86,7 @@ monitor_subsys_conn_init( } BER_BVSTR( &bv, "0" ); - attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); + attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, &bv ); mp = monitor_entrypriv_create(); if ( mp == NULL ) { @@ -139,7 +139,7 @@ monitor_subsys_conn_init( } BER_BVSTR( &bv, "0" ); - attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); + attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, &bv ); mp = monitor_entrypriv_create(); if ( mp == NULL ) { @@ -377,15 +377,13 @@ conn_create( buf3 ); - bv.bv_val = buf; - bv.bv_len = strlen( buf ); - attr_merge_one( e, mi->mi_ad_monitoredInfo, &bv, NULL ); + ber_str2bv( buf, 0, 0, &bv ); + attr_merge_one( e, mi->mi_ad_monitoredInfo, &bv, &bv ); /* connection number */ snprintf( buf, sizeof( buf ), "%ld", c->c_connid ); - bv.bv_val = buf; - bv.bv_len = strlen( buf ); - attr_merge_one( e, mi->mi_ad_monitorConnectionNumber, &bv, NULL ); + ber_str2bv( buf, 0, 0, &bv ); + attr_merge_one( e, mi->mi_ad_monitorConnectionNumber, &bv, &bv ); /* authz DN */ attr_merge_one( e, mi->mi_ad_monitorConnectionAuthzDN, @@ -393,11 +391,11 @@ conn_create( /* local address */ attr_merge_one( e, mi->mi_ad_monitorConnectionLocalAddress, - &c->c_sock_name, NULL ); + &c->c_sock_name, &bv ); /* peer address */ attr_merge_one( e, mi->mi_ad_monitorConnectionPeerAddress, - &c->c_peer_name, NULL ); + &c->c_peer_name, &bv ); mp = monitor_entrypriv_create(); if ( mp == NULL ) { diff --git a/servers/slapd/back-monitor/database.c b/servers/slapd/back-monitor/database.c index 8aa38f6c52..8d5ee6076b 100644 --- a/servers/slapd/back-monitor/database.c +++ b/servers/slapd/back-monitor/database.c @@ -81,7 +81,7 @@ init_readOnly( monitor_info_t *mi, Entry *e, slap_mask_t restrictops ) struct berval *tf = ( ( restrictops & SLAP_RESTRICT_OP_MASK ) == SLAP_RESTRICT_OP_WRITES ) ? (struct berval *)&slap_true_bv : (struct berval *)&slap_false_bv; - return attr_merge_one( e, mi->mi_ad_readOnly, tf, NULL ); + return attr_merge_one( e, mi->mi_ad_readOnly, tf, tf ); } static int @@ -92,7 +92,8 @@ init_restrictedOperation( monitor_info_t *mi, Entry *e, slap_mask_t restrictops for ( i = 0; restricted_ops[ i ].op.bv_val; i++ ) { if ( restrictops & restricted_ops[ i ].tag ) { rc = attr_merge_one( e, mi->mi_ad_restrictedOperation, - &restricted_ops[ i ].op, NULL ); + &restricted_ops[ i ].op, + &restricted_ops[ i ].op ); if ( rc ) { return rc; } @@ -102,7 +103,8 @@ init_restrictedOperation( monitor_info_t *mi, Entry *e, slap_mask_t restrictops for ( i = 0; restricted_exops[ i ].op.bv_val; i++ ) { if ( restrictops & restricted_exops[ i ].tag ) { rc = attr_merge_one( e, mi->mi_ad_restrictedOperation, - &restricted_exops[ i ].op, NULL ); + &restricted_exops[ i ].op, + &restricted_exops[ i ].op ); if ( rc ) { return rc; } @@ -261,8 +263,7 @@ monitor_subsys_database_init( break; } - bv.bv_val = on->on_bi.bi_type; - bv.bv_len = strlen( bv.bv_val ); + ber_str2bv( on->on_bi.bi_type, 0, 0, &bv ); attr_merge_normalize_one( e, mi->mi_ad_monitorOverlay, &bv, NULL ); @@ -277,8 +278,7 @@ monitor_subsys_database_init( snprintf( buf, sizeof( buf ), "cn=Overlay %d,%s", j, ms_overlay->mss_dn.bv_val ); - bv.bv_val = buf; - bv.bv_len = strlen( buf ); + ber_str2bv( buf, 0, 0, &bv ); attr_merge_normalize_one( e, mi->mi_ad_seeAlso, &bv, NULL ); } @@ -742,7 +742,7 @@ monitor_subsys_database_modify( if ( !bvmatch( &a->a_vals[ 0 ], tf ) ) { attr_delete( &e->e_attrs, mi->mi_ad_readOnly ); - rc = attr_merge_one( e, mi->mi_ad_readOnly, tf, NULL ); + rc = attr_merge_one( e, mi->mi_ad_readOnly, tf, tf ); } if ( rc == LDAP_SUCCESS ) { @@ -813,14 +813,16 @@ monitor_subsys_database_modify( for ( i = 0; !BER_BVISNULL( &restricted_ops[ i ].op ); i++ ) { if ( rp_add & restricted_ops[ i ].tag ) { attr_merge_one( e, mi->mi_ad_restrictedOperation, - &restricted_ops[ i ].op, NULL ); + &restricted_ops[ i ].op, + &restricted_ops[ i ].op ); } } for ( i = 0; !BER_BVISNULL( &restricted_exops[ i ].op ); i++ ) { if ( rp_add & restricted_exops[ i ].tag ) { attr_merge_one( e, mi->mi_ad_restrictedOperation, - &restricted_exops[ i ].op, NULL ); + &restricted_exops[ i ].op, + &restricted_exops[ i ].op ); } } } @@ -878,8 +880,7 @@ monitor_back_add_plugin( monitor_info_t *mi, Backend *be, Entry *e_database ) srchdesc->spd_version, srchdesc->spd_description ); - bv.bv_val = buf; - bv.bv_len = strlen( buf ); + ber_str2bv( buf, 0, 0, &bv ); attr_merge_normalize_one( e_database, mi->mi_ad_monitoredInfo, &bv, NULL ); diff --git a/servers/slapd/back-monitor/listener.c b/servers/slapd/back-monitor/listener.c index d94954e8d0..ae0453b62b 100644 --- a/servers/slapd/back-monitor/listener.c +++ b/servers/slapd/back-monitor/listener.c @@ -22,6 +22,7 @@ #include "portable.h" #include +#include #include "slap.h" #include "back-monitor.h" @@ -106,9 +107,7 @@ monitor_subsys_listener_init( if ( l[ i ]->sl_is_tls ) { struct berval bv; - bv.bv_val = "TLS"; - bv.bv_len = sizeof("TLS")-1; - + BER_BVSTR( &bv, "TLS" ); attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL ); } diff --git a/servers/slapd/back-monitor/log.c b/servers/slapd/back-monitor/log.c index 8ab11949e9..d2b528982e 100644 --- a/servers/slapd/back-monitor/log.c +++ b/servers/slapd/back-monitor/log.c @@ -119,7 +119,7 @@ monitor_subsys_log_init( } } - attr_merge( e, mi->mi_ad_description, desc, NULL ); + attr_merge_normalize( e, mi->mi_ad_description, desc, NULL ); monitor_cache_release( mi, e ); diff --git a/servers/slapd/back-monitor/operation.c b/servers/slapd/back-monitor/operation.c index 8ce09525d3..f071bb0d61 100644 --- a/servers/slapd/back-monitor/operation.c +++ b/servers/slapd/back-monitor/operation.c @@ -74,8 +74,8 @@ monitor_subsys_ops_init( return( -1 ); } - attr_merge_one( e_op, mi->mi_ad_monitorOpInitiated, &bv_zero, NULL ); - attr_merge_one( e_op, mi->mi_ad_monitorOpCompleted, &bv_zero, NULL ); + attr_merge_one( e_op, mi->mi_ad_monitorOpInitiated, &bv_zero, &bv_zero ); + attr_merge_one( e_op, mi->mi_ad_monitorOpCompleted, &bv_zero, &bv_zero ); mp = ( monitor_entry_t * )e_op->e_private; mp->mp_children = NULL; diff --git a/servers/slapd/back-monitor/overlay.c b/servers/slapd/back-monitor/overlay.c index c68d5152cd..01d8beb88e 100644 --- a/servers/slapd/back-monitor/overlay.c +++ b/servers/slapd/back-monitor/overlay.c @@ -103,9 +103,7 @@ monitor_subsys_overlay_init( return( -1 ); } - bv.bv_val = on->on_bi.bi_type; - bv.bv_len = strlen( bv.bv_val ); - + ber_str2bv( on->on_bi.bi_type, 0, 0, &bv ); attr_merge_normalize_one( e, mi->mi_ad_monitoredInfo, &bv, NULL ); attr_merge_normalize_one( e_overlay, mi->mi_ad_monitoredInfo, @@ -123,9 +121,8 @@ monitor_subsys_overlay_init( snprintf( buf, sizeof( buf ), "cn=Database %d,%s", j, ms_database->mss_dn.bv_val ); - dn.bv_val = buf; - dn.bv_len = strlen( buf ); + ber_str2bv( buf, 0, 0, &dn ); attr_merge_normalize_one( e, mi->mi_ad_seeAlso, &dn, NULL ); } diff --git a/servers/slapd/back-monitor/rww.c b/servers/slapd/back-monitor/rww.c index 1504846897..744c7a5511 100644 --- a/servers/slapd/back-monitor/rww.c +++ b/servers/slapd/back-monitor/rww.c @@ -110,7 +110,7 @@ monitor_subsys_rww_init( ber_dupbv( &monitor_rww[ i ].nrdn, &nrdn ); BER_BVSTR( &bv, "0" ); - attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); + attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, &bv ); mp = monitor_entrypriv_create(); if ( mp == NULL ) { diff --git a/servers/slapd/back-monitor/sent.c b/servers/slapd/back-monitor/sent.c index b7ba178f55..6b5f7e593b 100644 --- a/servers/slapd/back-monitor/sent.c +++ b/servers/slapd/back-monitor/sent.c @@ -114,7 +114,7 @@ monitor_subsys_sent_init( ber_dupbv( &monitor_sent[ i ].nrdn, &nrdn ); BER_BVSTR( &bv, "0" ); - attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, NULL ); + attr_merge_one( e, mi->mi_ad_monitorCounter, &bv, &bv ); mp = monitor_entrypriv_create(); if ( mp == NULL ) { -- 2.39.5