From: Kurt Zeilenga Date: Mon, 24 Dec 2001 18:38:20 +0000 (+0000) Subject: Require the struct berval **out argument of dnPretty/dnNormalize X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~539 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d047cc854ed9b18fa76983db1fb8b9a85906c15a;p=openldap Require the struct berval **out argument of dnPretty/dnNormalize point to a NULL pointer, that is assert( *out == NULL ). Eventually, we'll allow **out to point to a preallocated struct berval (to avoid unnecessary allocation). --- diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 5c061745ae..f54bb8a933 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -232,7 +232,7 @@ parse_acl( if( a->acl_dn_pat.bv_len != 0 ) { if ( a->acl_dn_style != ACL_STYLE_REGEX ) { - struct berval *bv; + struct berval *bv = NULL; dnNormalize( NULL, &a->acl_dn_pat, &bv); free( a->acl_dn_pat.bv_val ); a->acl_dn_pat = *bv; diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 2050fecd34..3127b8664b 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -87,7 +87,7 @@ do_add( Connection *conn, Operation *op ) e->e_private = NULL; { - struct berval *pdn; + struct berval *pdn = NULL; rc = dnPretty( NULL, &dn, &pdn ); if( rc != LDAP_SUCCESS ) { @@ -108,7 +108,7 @@ do_add( Connection *conn, Operation *op ) } { - struct berval *ndn; + struct berval *ndn = NULL; rc = dnNormalize( NULL, &dn, &ndn ); if( rc != LDAP_SUCCESS ) { diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index ed81bf5a14..38ecca3af3 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -311,6 +311,8 @@ dnNormalize( assert( val ); assert( normalized ); + assert( *normalized == NULL ); + if ( val->bv_len != 0 ) { LDAPDN *dn = NULL; char *dn_out = NULL; @@ -371,6 +373,7 @@ dnPretty( assert( val ); assert( pretty ); + assert( *pretty == NULL ); if ( val->bv_len != 0 ) { LDAPDN *dn = NULL; @@ -477,7 +480,8 @@ dnMatch( char * dn_validate( char *dn ) { - struct berval val, *pretty; + struct berval val; + struct berval *pretty = NULL; int rc; if ( dn == NULL || dn[0] == '\0' ) { @@ -512,7 +516,8 @@ dn_validate( char *dn ) char * dn_normalize( char *dn ) { - struct berval val, *normalized; + struct berval val; + struct berval *normalized = NULL; int rc; if ( dn == NULL || dn[0] == '\0' ) { diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index a0acd7a33f..af1eb92f4e 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -117,7 +117,7 @@ str2entry( char *s ) } if ( strcasecmp( type, "dn" ) == 0 ) { - struct berval *pdn; + struct berval *pdn = NULL; free( type ); @@ -156,7 +156,8 @@ str2entry( char *s ) return NULL; } - e->e_name.bv_val = pdn->bv_val != NULL ? pdn->bv_val : ch_strdup( "" ); + e->e_name.bv_val = pdn->bv_val != NULL + ? pdn->bv_val : ch_strdup( "" ); e->e_name.bv_len = pdn->bv_len; free( pdn ); continue; @@ -290,10 +291,9 @@ str2entry( char *s ) /* generate normalized dn */ { - struct berval *ndn; + struct berval *ndn = NULL; rc = dnNormalize( NULL, &e->e_name, &ndn ); - if( rc != LDAP_SUCCESS ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_INFO,