]> git.sur5r.net Git - openldap/commitdiff
Replace strcat with slap_strcopy
authorHoward Chu <hyc@openldap.org>
Wed, 26 Dec 2001 16:25:18 +0000 (16:25 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 26 Dec 2001 16:25:18 +0000 (16:25 +0000)
servers/slapd/aclparse.c
servers/slapd/configinfo.c
servers/slapd/daemon.c
servers/slapd/dn.c
servers/slapd/lock.c

index 5a28ebfd749d5f0e1759ee02390f412c1b5b0f21..7c5d27f4c8693d3a7cb40b61a8416c62765c8774 100644 (file)
@@ -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;
 }
index 51c2b472fc6e845f3fffeeca138d6677f78f9909..5102bb2004de0c7b0a95794e233ae8db5794f2ff 100644 (file)
@@ -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 );
        }
 
index 911db57cd54f68b91af3add7284a032b9244bfbe..b024e50a2a9abf59f26c20b6ad324bbc38f436f3 100644 (file)
@@ -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 );
                        }
index 3b757a8625605e58743371eb6e95600239d44dd1..a36123dc4ae1aa91ab080f2daf9885a0fb407fdf 100644 (file)
@@ -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 */
index 856c6c7fb418f9f0ed0aa446112f148073e35f46..b56a251fdcd131295bef6a2b344d4cd94894ef1c 100644 (file)
@@ -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,