From 999b3dad7b9344cb55fc1adefd075bce1c1aa0b8 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Wed, 5 Dec 2001 01:16:12 +0000 Subject: [PATCH] Fix replacing of all values with an empty value. --- servers/slapd/modify.c | 32 ++++++++++++++++++++++++++++++-- servers/slapd/value.c | 7 +++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index 783d9ac89f..c8a616d5e7 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -220,7 +220,7 @@ do_modify( #ifdef LDAP_DEBUG #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, - "do_modify: modifications:\n" )); + "do_modify: modifications:\n" )); #else Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 ); #endif @@ -231,13 +231,41 @@ do_modify( "\t%s: %s\n", tmp->ml_op == LDAP_MOD_ADD ? "add" : (tmp->ml_op == LDAP_MOD_DELETE ? "delete" : "replace"), tmp->ml_type )); + + if ( tmp->ml_bvalues == NULL ) { + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "\t\tno values" )); + } else if ( tmp->ml_bvalues[0] == NULL ) { + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "\t\tzero values" )); + } else if ( tmp->ml_bvalues[1] == NULL ) { + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "\t\tone value" )); + } else { + LDAP_LOG(( "operation", LDAP_LEVEL_DETAIL1, + "\t\tmultiple values" )); + } + #else Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n", tmp->ml_op == LDAP_MOD_ADD ? "add" : (tmp->ml_op == LDAP_MOD_DELETE ? "delete" : "replace"), tmp->ml_type, 0 ); -#endif + if ( tmp->ml_bvalues == NULL ) { + Debug( LDAP_DEBUG_ARGS, "%s\n", + "\t\tno values", NULL, NULL ); + } else if ( tmp->ml_bvalues[0] == NULL ) { + Debug( LDAP_DEBUG_ARGS, "%s\n", + "\t\tzero values", NULL, NULL ); + } else if ( tmp->ml_bvalues[1] == NULL ) { + Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n", + "\t\tone value", (long) tmp->ml_bvalues[0]->bv_len, NULL ); + } else { + Debug( LDAP_DEBUG_ARGS, "%s\n", + "\t\tmultiple values", NULL, NULL ); + } +#endif } #endif diff --git a/servers/slapd/value.c b/servers/slapd/value.c index 88768204bd..cb87d5e4e2 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -33,6 +33,7 @@ value_add( *vals = (struct berval **) ch_malloc( (nn + 1) * sizeof(struct berval *) ); n = 0; + } else { for ( n = 0; (*vals)[n] != NULL; n++ ) ; /* NULL */ @@ -41,10 +42,8 @@ value_add( } for ( i = 0, j = 0; i < nn; i++ ) { - if ( addvals[i]->bv_len > 0 ) { - (*vals)[n + j] = ber_bvdup( addvals[i] ); - if( (*vals)[n + j++] == NULL ) break; - } + (*vals)[n + j] = ber_bvdup( addvals[i] ); + if( (*vals)[n + j++] == NULL ) break; } (*vals)[n + j] = NULL; -- 2.39.5