From: Howard Chu Date: Wed, 26 Dec 2001 16:25:18 +0000 (+0000) Subject: Replace strcat with slap_strcopy X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~495 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bbcb0f8a7f7484c67c8d1aa49288601421269ddf;p=openldap Replace strcat with slap_strcopy --- diff --git a/servers/slapd/aclparse.c b/servers/slapd/aclparse.c index 5a28ebfd74..7c5d27f4c8 100644 --- a/servers/slapd/aclparse.c +++ b/servers/slapd/aclparse.c @@ -983,6 +983,7 @@ char * accessmask2str( slap_mask_t mask, char *buf ) { int none=1; + char *ptr = buf; assert( buf != NULL ); @@ -994,75 +995,75 @@ accessmask2str( slap_mask_t mask, char *buf ) if ( ACL_IS_LEVEL( mask ) ) { if ( ACL_LVL_IS_NONE(mask) ) { - strcat( buf, "none" ); + ptr = slap_strcopy( ptr, "none" ); } else if ( ACL_LVL_IS_AUTH(mask) ) { - strcat( buf, "auth" ); + ptr = slap_strcopy( ptr, "auth" ); } else if ( ACL_LVL_IS_COMPARE(mask) ) { - strcat( buf, "compare" ); + ptr = slap_strcopy( ptr, "compare" ); } else if ( ACL_LVL_IS_SEARCH(mask) ) { - strcat( buf, "search" ); + ptr = slap_strcopy( ptr, "search" ); } else if ( ACL_LVL_IS_READ(mask) ) { - strcat( buf, "read" ); + ptr = slap_strcopy( ptr, "read" ); } else if ( ACL_LVL_IS_WRITE(mask) ) { - strcat( buf, "write" ); + ptr = slap_strcopy( ptr, "write" ); } else { - strcat( buf, "unknown" ); + ptr = slap_strcopy( ptr, "unknown" ); } - strcat(buf, " ("); + *ptr++ = '('; } if( ACL_IS_ADDITIVE( mask ) ) { - strcat( buf, "+" ); + *ptr++ = '+'; } else if( ACL_IS_SUBTRACTIVE( mask ) ) { - strcat( buf, "-" ); + *ptr++ = '-'; } else { - strcat( buf, "=" ); + *ptr++ = '='; } if ( ACL_PRIV_ISSET(mask, ACL_PRIV_WRITE) ) { none = 0; - strcat( buf, "w" ); + *ptr++ = 'w'; } if ( ACL_PRIV_ISSET(mask, ACL_PRIV_READ) ) { none = 0; - strcat( buf, "r" ); + *ptr++ = 'r'; } if ( ACL_PRIV_ISSET(mask, ACL_PRIV_SEARCH) ) { none = 0; - strcat( buf, "s" ); + *ptr++ = 's'; } if ( ACL_PRIV_ISSET(mask, ACL_PRIV_COMPARE) ) { none = 0; - strcat( buf, "c" ); + *ptr++ = 'c'; } if ( ACL_PRIV_ISSET(mask, ACL_PRIV_AUTH) ) { none = 0; - strcat( buf, "x" ); + *ptr++ = 'x'; } if ( none && ACL_PRIV_ISSET(mask, ACL_PRIV_NONE) ) { none = 0; - strcat( buf, "n" ); + *ptr++ = 'n'; } if ( none ) { - strcat( buf, "0" ); + *ptr++ = '0'; } if ( ACL_IS_LEVEL( mask ) ) { - strcat(buf, ")"); + *ptr = ')'; } return buf; } diff --git a/servers/slapd/configinfo.c b/servers/slapd/configinfo.c index 51c2b472fc..5102bb2004 100644 --- a/servers/slapd/configinfo.c +++ b/servers/slapd/configinfo.c @@ -36,7 +36,7 @@ config_info( { Entry *e; char buf[BUFSIZ]; - struct berval val; + struct berval val, *ndn = NULL; struct berval *vals[2]; int i, j; @@ -46,9 +46,10 @@ config_info( e = (Entry *) ch_calloc( 1, sizeof(Entry) ); e->e_attrs = NULL; - e->e_dn = ch_strdup( SLAPD_CONFIG_DN ); - e->e_ndn = ch_strdup( SLAPD_CONFIG_DN ); - (void) dn_normalize( e->e_ndn ); + ber_str2bv( SLAPD_CONFIG_DN, sizeof(SLAPD_CONFIG_DN)-1, 1, &e->e_name ); + dnNormalize( NULL, &e->e_name, &ndn ); + e->e_nname = *ndn; + free( ndn ); e->e_private = NULL; val.bv_val = "top"; @@ -64,27 +65,25 @@ config_info( attr_merge( e, "objectClass", vals ); { - char *rdn = ch_strdup( SLAPD_CONFIG_DN ); - val.bv_val = strchr( rdn, '=' ); + val.bv_val = strchr( e->e_dn, '=' ); if( val.bv_val != NULL ) { - *val.bv_val = '\0'; - val.bv_len = strlen( ++val.bv_val ); + *val.bv_val++ = '\0'; + val.bv_len = e->e_name.bv_len - (val.bv_val-e->e_dn); attr_merge( e, rdn, vals ); + val.bv_val[-1] = '='; } - - free( rdn ); } for ( i = 0; i < nbackends; i++ ) { - strcpy( buf, backends[i].be_type ); + char *ptr = slap_strcopy( buf, backends[i].be_type ); for ( j = 0; backends[i].be_suffix[j] != NULL; j++ ) { - strcat( buf, " : " ); - strcat( buf, backends[i].be_suffix[j]->bv_val ); + ptr = slap_strcopy( ptr, " : " ); + ptr = slap_strcopy( ptr, backends[i].be_suffix[j]->bv_val ); } val.bv_val = buf; - val.bv_len = strlen( buf ); + val.bv_len = ptr - buf; attr_merge( e, "database", vals ); } diff --git a/servers/slapd/daemon.c b/servers/slapd/daemon.c index 911db57cd5..b024e50a2a 100644 --- a/servers/slapd/daemon.c +++ b/servers/slapd/daemon.c @@ -114,8 +114,8 @@ void slapd_slp_init( const char* urls ) { slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i], strlen( host ) + sizeof( LDAP_SRVTYPE_PREFIX ) ); - strcpy( slapd_srvurls[i], LDAP_SRVTYPE_PREFIX ); - strcat( slapd_srvurls[i], host ); + strcpy( slap_strcopy(slapd_srvurls[i], + LDAP_SRVTYPE_PREFIX ), host ); ch_free( host ); } @@ -126,8 +126,8 @@ void slapd_slp_init( const char* urls ) { slapd_srvurls[i] = (char *) realloc( slapd_srvurls[i], strlen( host ) + sizeof( LDAPS_SRVTYPE_PREFIX ) ); - strcpy( slapd_srvurls[i], LDAPS_SRVTYPE_PREFIX ); - strcat( slapd_srvurls[i], host ); + strcpy( slap_strcopy(slapd_srvurls[i], + LDAPS_SRVTYPE_PREFIX ), host ); ch_free( host ); } diff --git a/servers/slapd/dn.c b/servers/slapd/dn.c index 3b757a8625..a36123dc4a 100644 --- a/servers/slapd/dn.c +++ b/servers/slapd/dn.c @@ -929,6 +929,7 @@ build_new_dn( char ** new_dn, const char * parent_dn, const char * newrdn ) { + char *ptr; if ( parent_dn == NULL ) { *new_dn = ch_strdup( newrdn ); @@ -938,9 +939,9 @@ build_new_dn( char ** new_dn, *new_dn = (char *) ch_malloc( strlen( parent_dn ) + strlen( newrdn ) + 2 ); - strcpy( *new_dn, newrdn ); - strcat( *new_dn, "," ); - strcat( *new_dn, parent_dn ); + ptr = slap_strcopy( *new_dn, newrdn ); + *ptr++ = ','; + strcpy( ptr, parent_dn ); } #endif /* SLAP_DN_MIGRATION */ diff --git a/servers/slapd/lock.c b/servers/slapd/lock.c index 856c6c7fb4..b56a251fdc 100644 --- a/servers/slapd/lock.c +++ b/servers/slapd/lock.c @@ -27,8 +27,7 @@ lock_fopen( const char *fname, const char *type, FILE **lfp ) char buf[MAXPATHLEN]; /* open the lock file */ - strcpy( buf, fname ); - strcat( buf, ".lock" ); + strcpy(slap_strcopy( buf, fname ), ".lock" ); if ( (*lfp = fopen( buf, "w" )) == NULL ) { #ifdef NEW_LOGGING LDAP_LOG(( "operation", LDAP_LEVEL_ERR,