diff options
Diffstat (limited to 'ldap/admin')
-rw-r--r-- | ldap/admin/include/dsalib.h | 4 | ||||
-rw-r--r-- | ldap/admin/lib/dsalib_debug.c | 10 | ||||
-rw-r--r-- | ldap/admin/lib/dsalib_dn.c | 23 | ||||
-rw-r--r-- | ldap/admin/lib/dsalib_filename.c | 3 | ||||
-rw-r--r-- | ldap/admin/lib/dsalib_ldif.c | 3 | ||||
-rw-r--r-- | ldap/admin/lib/dsalib_location.c | 3 | ||||
-rw-r--r-- | ldap/admin/lib/dsalib_tailf.c | 3 | ||||
-rw-r--r-- | ldap/admin/lib/dsalib_util.c | 8 | ||||
-rw-r--r-- | ldap/admin/src/addindex.c | 5 | ||||
-rw-r--r-- | ldap/admin/src/create_instance.c | 52 | ||||
-rw-r--r-- | ldap/admin/src/latest_file.c | 3 | ||||
-rw-r--r-- | ldap/admin/src/script-gen.c | 3 |
12 files changed, 53 insertions, 67 deletions
diff --git a/ldap/admin/include/dsalib.h b/ldap/admin/include/dsalib.h index e7f1378e..b2fb483f 100644 --- a/ldap/admin/include/dsalib.h +++ b/ldap/admin/include/dsalib.h @@ -329,10 +329,6 @@ extern DS_EXPORT_SYMBOL char* dn_normalize_convert (char* DN); /* if dn contains an unescaped quote return true */ extern DS_EXPORT_SYMBOL int ds_dn_uses_LDAPv2_quoting(const char *dn); -/* Return != 0 iff the DN equals or ends with the given suffix. - Both DN and suffix must be normalized, by dn_normalize(). */ -extern DS_EXPORT_SYMBOL int dn_issuffix (char* DN, char* suffix); - /* Return a copy of the DN, but with optional whitespace inserted. */ extern DS_EXPORT_SYMBOL char* ds_dn_expand (char* DN); diff --git a/ldap/admin/lib/dsalib_debug.c b/ldap/admin/lib/dsalib_debug.c index 797b84dc..5c777845 100644 --- a/ldap/admin/lib/dsalib_debug.c +++ b/ldap/admin/lib/dsalib_debug.c @@ -11,6 +11,7 @@ #include <string.h> #include <stdlib.h> #include "nspr.h" +#include "plstr.h" #if defined( XP_WIN32 ) int ldap_debug = 0; @@ -23,8 +24,7 @@ ds_log_env(char **envp) char admin_logfile[PATH_MAX], *tmp_dir; tmp_dir = ds_get_tmp_dir(); - memset( admin_logfile, 0, sizeof( admin_logfile ) ); - strcat( admin_logfile, tmp_dir ); + PL_strncpyz( admin_logfile, tmp_dir, sizeof(admin_logfile) ); #if defined( XP_WIN32 ) if( tmp_dir ) { @@ -32,7 +32,7 @@ ds_log_env(char **envp) tmp_dir = NULL; } #endif - strcat( admin_logfile, "/admin.log"); + PL_strcatn( admin_logfile, sizeof(admin_logfile), "/admin.log"); file = fopen(admin_logfile, "a+"); if (file != NULL) { @@ -55,7 +55,7 @@ ds_log_debug_message(char *msg) tmp_dir = ds_get_tmp_dir(); memset( admin_logfile, 0, sizeof( admin_logfile ) ); - strcat( admin_logfile, tmp_dir ); + PL_strncpyz( admin_logfile, tmp_dir, sizeof(admin_logfile) ); #if defined( XP_WIN32 ) if( tmp_dir ) { @@ -63,7 +63,7 @@ ds_log_debug_message(char *msg) tmp_dir = NULL; } #endif - strcat( admin_logfile, "/admin.log"); + PL_strcatn( admin_logfile, sizeof(admin_logfile), "/admin.log"); file = fopen(admin_logfile, "a+"); if (file != NULL) { diff --git a/ldap/admin/lib/dsalib_dn.c b/ldap/admin/lib/dsalib_dn.c index 89f03f1f..381f04e8 100644 --- a/ldap/admin/lib/dsalib_dn.c +++ b/ldap/admin/lib/dsalib_dn.c @@ -126,28 +126,6 @@ dn_normalize( char *dn ) return( dn ); } -DS_EXPORT_SYMBOL int -dn_issuffix( - char *dn, - char *suffix -) -{ - int dnlen, suffixlen; - - if ( dn == NULL ) { - return( 0 ); - } - - suffixlen = strlen( suffix ); - dnlen = strlen( dn ); - - if ( suffixlen > dnlen ) { - return( 0 ); - } - - return( strcasecmp( dn + dnlen - suffixlen, suffix ) == 0 ); -} - DS_EXPORT_SYMBOL char* ds_dn_expand (char* dn) { @@ -159,6 +137,7 @@ ds_dn_expand (char* dn) if (dn == NULL) return NULL; edn = strdup (dn); + if (edn == NULL) return NULL; for (s = dn; *s != '\0'; ++s, ++i) { switch (state) { case B4TYPE: diff --git a/ldap/admin/lib/dsalib_filename.c b/ldap/admin/lib/dsalib_filename.c index 6007176c..117b8952 100644 --- a/ldap/admin/lib/dsalib_filename.c +++ b/ldap/admin/lib/dsalib_filename.c @@ -55,10 +55,9 @@ ds_get_file_meaning(char *file) if ( file == NULL ) return(NULL); - name = malloc(strlen(file) + 1); + name = strdup(file); if ( name == NULL ) return(NULL); - strcpy(name, file); if ( (tmp = strrchr(name, '.')) != NULL ) *tmp = '\0'; if ( strlen(name) == FILE_EXPECTED_SIZE1 ) { diff --git a/ldap/admin/lib/dsalib_ldif.c b/ldap/admin/lib/dsalib_ldif.c index 3a126ce8..40c0ae8c 100644 --- a/ldap/admin/lib/dsalib_ldif.c +++ b/ldap/admin/lib/dsalib_ldif.c @@ -20,6 +20,7 @@ #include <string.h> #include <errno.h> #include "nspr.h" +#include "plstr.h" #ifndef XP_WIN32 #define SCRIPT_SUFFIX "" /* shell scripts have no suffix */ @@ -303,7 +304,7 @@ ds_db2ldif_subtree(char *file, char *subtree) if ( file == NULL ) *outfile = 0; else - strcpy( outfile, file ); + PL_strncpyz( outfile, file, sizeof(outfile) ); PR_snprintf(scriptfile, PATH_MAX, "%s%cdb2ldif", root, FILE_SEP); diff --git a/ldap/admin/lib/dsalib_location.c b/ldap/admin/lib/dsalib_location.c index 600cc19c..d5057349 100644 --- a/ldap/admin/lib/dsalib_location.c +++ b/ldap/admin/lib/dsalib_location.c @@ -11,6 +11,7 @@ #include <string.h> #include <stdlib.h> #include "nspr.h" +#include "plstr.h" /* * Returns the server root. Info is @@ -118,7 +119,7 @@ ds_get_logfile_name(int config_type) free(filename); return(NULL); } - strncpy(logfile, filename, PATH_MAX); + PL_strncpyz(logfile, filename, sizeof(logfile)); free(filename); return(logfile); } diff --git a/ldap/admin/lib/dsalib_tailf.c b/ldap/admin/lib/dsalib_tailf.c index db539479..62143db4 100644 --- a/ldap/admin/lib/dsalib_tailf.c +++ b/ldap/admin/lib/dsalib_tailf.c @@ -13,6 +13,7 @@ #include <sys/stat.h> #include "dsalib.h" #include "prthread.h" +#include "plstr.h" /* * Function: adjustFile @@ -166,7 +167,7 @@ ds_display_tail(char *fileName, int timeOut, int startSeek, char *doneMsg, { char *tmp; if (lastLine != NULL) - strcpy(lastLine, msgBuf); + PL_strncpyz(lastLine, msgBuf, BIG_LINE); if ( (tmp = strchr(msgBuf, ((int) '\n'))) != NULL ) *tmp = '\0'; /* strip out real newlines from here */ ds_send_status(msgBuf); diff --git a/ldap/admin/lib/dsalib_util.c b/ldap/admin/lib/dsalib_util.c index 1f8335fa..c17d3747 100644 --- a/ldap/admin/lib/dsalib_util.c +++ b/ldap/admin/lib/dsalib_util.c @@ -290,9 +290,11 @@ ds_get_tmp_dir() if(instanceDir == NULL) { #if defined( XP_WIN32 ) - ilen = strlen(tmp); - GetTempPath( ilen +1, tmp ); + ilen = sizeof(tmp); + GetTempPath( ilen, tmp ); + tmp[ilen-1] = (char)0; /* Remove trailing slash. */ + ilen = strlen(tmp); pch = tmp[ilen-1]; if( pch == '\\' || pch == '/' ) tmp[ilen-1] = '\0'; @@ -642,7 +644,7 @@ alter_startup_line(char *startup_line) char temp_startup_line[BIG_LINE+40]; PR_snprintf(temp_startup_line, sizeof(temp_startup_line), "/bin/sh -c \"%s\"", startup_line); - strcpy(startup_line, temp_startup_line); + PL_strncpyz(startup_line, temp_startup_line, BIG_LINE); #else /* do nothing */ #endif /* Linux */ diff --git a/ldap/admin/src/addindex.c b/ldap/admin/src/addindex.c index 608bef6f..84b0bdbf 100644 --- a/ldap/admin/src/addindex.c +++ b/ldap/admin/src/addindex.c @@ -51,6 +51,11 @@ int main(int argc, char *argv[]) attrs = strdup( attributes ); + if (attrs == NULL) { + rpt_err(DS_MEMORY_ERROR, "Out of memory!", NULL, NULL); + return 1; + } + /* Allocate for worst possible case */ attrList = (char **)malloc(sizeof(*attrList) * (strlen(attrs)+1)); nAttrs = 0; diff --git a/ldap/admin/src/create_instance.c b/ldap/admin/src/create_instance.c index d2a332ac..cd81741f 100644 --- a/ldap/admin/src/create_instance.c +++ b/ldap/admin/src/create_instance.c @@ -440,21 +440,21 @@ static char *sanity_check(server_config_s *cf, char *param_name) { if( (t = create_instance_checkport(cf->bindaddr, cf->servport)) ) { - strcpy(param_name, "servport"); + PL_strncpyz(param_name, "servport", BIG_LINE); return t; } if ( cf->secserv && (strcmp(cf->secserv, "on") == 0) && (cf->secservport != NULL) && (*(cf->secservport) != '\0') ) { if ( (t = create_instance_checkport(cf->bindaddr, cf->secservport)) ) { - strcpy(param_name, "secservport"); + PL_strncpyz(param_name, "secservport", BIG_LINE); return t; } } if ( cf->ntsynch && (strcmp(cf->ntsynch, "on") == 0) && (cf->ntsynchport != NULL) && (*(cf->ntsynchport) != '\0') ) { if ( (t = create_instance_checkport(cf->bindaddr, cf->ntsynchport)) ) { - strcpy(param_name, "ntsynchport"); + PL_strncpyz(param_name, "ntsynchport", BIG_LINE); return t; } } @@ -463,7 +463,7 @@ static char *sanity_check(server_config_s *cf, char *param_name) /* is the server identifier good? */ for(x=0; cf->servid[x]; x++) { if(strchr("/ &;`'\"|*!?~<>^()[]{}$\\", cf->servid[x])) { - strcpy(param_name, "servid"); + PL_strncpyz(param_name, "servid", BIG_LINE); return make_error("You used a shell-specific character in " "your server id (the character was %c).", cf->servid[x]); @@ -476,7 +476,7 @@ static char *sanity_check(server_config_s *cf, char *param_name) /* Not an error to upgrade! ??? if ( !cf->upgradingServer ) { if(create_instance_exists(fn)) { - strcpy(param_name, "servid"); + PL_strncpyz(param_name, "servid", BIG_LINE); return make_error ("A server named '%s' already exists." "\nPlease choose another server identifier.", cf->servid); @@ -487,7 +487,7 @@ static char *sanity_check(server_config_s *cf, char *param_name) #ifdef XP_UNIX if( (t = create_instance_checkuser(cf->servuser)) ) { - strcpy(param_name, "servuser"); + PL_strncpyz(param_name, "servuser", BIG_LINE); return t; } #endif @@ -496,53 +496,53 @@ static char *sanity_check(server_config_s *cf, char *param_name) #ifdef XP_UNIX if((!create_instance_numbers(cf->numprocs)) || (atoi(cf->numprocs) <= 0)) { - strcpy(param_name, "numprocs"); + PL_strncpyz(param_name, "numprocs", BIG_LINE); return ("The number of processes must be not be zero or " "negative."); } #endif if((!create_instance_numbers(cf->maxthreads)) || (atoi(cf->maxthreads) <= 0)) { - strcpy(param_name, "maxthreads"); + PL_strncpyz(param_name, "maxthreads", BIG_LINE); return ("The maximum threads must be not be zero or negative."); } if((!create_instance_numbers(cf->minthreads)) || (atoi(cf->minthreads) <= 0)) { - strcpy(param_name, "minthreads"); + PL_strncpyz(param_name, "minthreads", BIG_LINE); return ("The minumum threads must be not be zero or negative."); } if((atoi(cf->minthreads)) > (atoi(cf->maxthreads))) { - strcpy(param_name, "minthreads"); + PL_strncpyz(param_name, "minthreads", BIG_LINE); return ("Minimum threads must be less than maximum threads."); } /* see if the DN parameters are valid DNs */ if (!cf->use_existing_user_ds && (t = isAValidDN(cf->suffix))) { - strcpy(param_name, "suffix"); + PL_strncpyz(param_name, "suffix", BIG_LINE); return t; } checkForLDAPv2Quoting(cf->suffix); if (NULL != (t = isAValidDN(cf->rootdn))) { - strcpy(param_name, "rootdn"); + PL_strncpyz(param_name, "rootdn", BIG_LINE); return t; } checkForLDAPv2Quoting(cf->rootdn); if (cf->replicationdn && *cf->replicationdn && (t = isAValidDN(cf->replicationdn))) { - strcpy(param_name, "replicationdn"); + PL_strncpyz(param_name, "replicationdn", BIG_LINE); return t; } checkForLDAPv2Quoting(cf->replicationdn); if (cf->consumerdn && *cf->consumerdn && (t = isAValidDN(cf->consumerdn))) { - strcpy(param_name, "consumerdn"); + PL_strncpyz(param_name, "consumerdn", BIG_LINE); return t; } checkForLDAPv2Quoting(cf->consumerdn); @@ -550,7 +550,7 @@ static char *sanity_check(server_config_s *cf, char *param_name) if (cf->changelogsuffix && *cf->changelogsuffix && (t = isAValidDN(cf->changelogsuffix))) { - strcpy(param_name, "changelogsuffix"); + PL_strncpyz(param_name, "changelogsuffix", BIG_LINE); return t; } checkForLDAPv2Quoting(cf->changelogsuffix); @@ -558,7 +558,7 @@ static char *sanity_check(server_config_s *cf, char *param_name) if (cf->netscaperoot && *cf->netscaperoot && (t = isAValidDN(cf->netscaperoot))) { - strcpy(param_name, "netscaperoot"); + PL_strncpyz(param_name, "netscaperoot", BIG_LINE); return t; } checkForLDAPv2Quoting(cf->netscaperoot); @@ -566,32 +566,32 @@ static char *sanity_check(server_config_s *cf, char *param_name) if (cf->samplesuffix && *cf->samplesuffix && (t = isAValidDN(cf->samplesuffix))) { - strcpy(param_name, "samplesuffix"); + PL_strncpyz(param_name, "samplesuffix", BIG_LINE); return t; } checkForLDAPv2Quoting(cf->samplesuffix); if (NULL != (t = contains8BitChars(cf->rootpw))) { - strcpy(param_name, "rootpw"); + PL_strncpyz(param_name, "rootpw", BIG_LINE); return t; } if (NULL != (t = contains8BitChars(cf->cfg_sspt_uidpw))) { - strcpy(param_name, "cfg_sspt_uidpw"); + PL_strncpyz(param_name, "cfg_sspt_uidpw", BIG_LINE); return t; } if (NULL != (t = contains8BitChars(cf->replicationpw))) { - strcpy(param_name, "replicationpw"); + PL_strncpyz(param_name, "replicationpw", BIG_LINE); return t; } if (NULL != (t = contains8BitChars(cf->consumerpw))) { - strcpy(param_name, "consumerpw"); + PL_strncpyz(param_name, "consumerpw", BIG_LINE); return t; } @@ -605,7 +605,7 @@ static char *sanity_check(server_config_s *cf, char *param_name) { if (NULL != (t = contains8BitChars(cf->cfg_sspt_uid))) { - strcpy(param_name, "cfg_sspt_uid"); + PL_strncpyz(param_name, "cfg_sspt_uid", BIG_LINE); return t; } } @@ -1107,7 +1107,7 @@ char *create_server(server_config_s *cf, char *param_name) #else /* Abort if the service exists on NT */ if (t = service_exists(cf->servid)) { - strcpy(param_name, "servid"); + PL_strncpyz(param_name, "servid", BIG_LINE); return t; } #endif @@ -4397,7 +4397,7 @@ static char *install_ds(char *sroot, server_config_s *cf, char *param_name) /* find the server's UID and GID */ if (cf->servuser && *(cf->servuser)) { if ((pw = getpwnam (cf->servuser)) == NULL) { - strcpy(param_name, "servuser"); + PL_strncpyz(param_name, "servuser", BIG_LINE); return make_error("Could not find UID and GID of user '%s'.", cf->servuser); } else if (pw->pw_name == NULL) { @@ -4606,11 +4606,11 @@ static char *install_ds(char *sroot, server_config_s *cf, char *param_name) memset(&slapd_conf, 0, sizeof(SLAPD_CONFIG)); if (sroot) - strcpy(slapd_conf.slapd_server_root, sroot); + PL_strncpyz(slapd_conf.slapd_server_root, sroot, sizeof(slapd_conf.slapd_server_root)); if (cf->servport) slapd_conf.port = atoi(cf->servport); if (cf->servname) - strcpy(slapd_conf.host, cf->servname); + PL_strncpyz(slapd_conf.host, cf->servname, sizeof(slapd_conf.host)); status = config_suitespot(&slapd_conf, &query_vars); if (status == -1) /* invalid or null arguments or configuration */ diff --git a/ldap/admin/src/latest_file.c b/ldap/admin/src/latest_file.c index 41f27d9a..a68ea01b 100644 --- a/ldap/admin/src/latest_file.c +++ b/ldap/admin/src/latest_file.c @@ -56,7 +56,8 @@ int main (int argc, char **argv) szOutput = argv[2]; /* Get directory part of path */ - strcpy( dir, szWildcardFileSpec ); + strncpy( dir, szWildcardFileSpec, sizeof(dir)-1 ); + dir[sizeof(dir)-1] = (char)0; dirEnd = strrchr( dir, '\\' ); if ( dirEnd != NULL ) { *dirEnd = 0; diff --git a/ldap/admin/src/script-gen.c b/ldap/admin/src/script-gen.c index 0f93406a..bc364c9d 100644 --- a/ldap/admin/src/script-gen.c +++ b/ldap/admin/src/script-gen.c @@ -79,7 +79,8 @@ int generate_script(const char *inpath, const char *outpath, int mode, /* not enough room, scratch it */ continue; } - strcpy(save_buffer, q+2); + strncpy(save_buffer, q+2, sizeof(save_buffer)-1); + save_buffer[sizeof(save_buffer)-1] = (char)0; strcpy(p, table[i][1]); strcat(p, save_buffer); q = p; |