From 28e51ad4d4c1d71a06b81ec73f7282e500e07cb4 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 27 Sep 2018 10:31:12 -0700 Subject: [PATCH] opal: convert from strncpy() -> opal_string_copy() In many cases, this was a simple string replace. In a few places, it entailed: 1. Updating some comments and removing now-redundant foo[size-1]='\0' statements. 2. Updating passing (size-1) to (size) (because opal_string_copy() wants the entire destination buffer length). This commit actually fixes a bunch of potential (yet quite unlikely) bugs where we could have ended up with non-null-terminated strings. Signed-off-by: Jeff Squyres --- opal/mca/base/mca_base_component_repository.c | 9 +-- opal/mca/btl/openib/btl_openib_ini.c | 3 +- opal/mca/btl/usnic/btl_usnic_cagent.c | 3 +- opal/mca/btl/usnic/btl_usnic_cclient.c | 13 +-- opal/mca/btl/usnic/btl_usnic_proc.c | 5 +- opal/mca/if/bsdx_ipv4/if_bsdx.c | 3 +- opal/mca/if/bsdx_ipv6/if_bsdx_ipv6.c | 3 +- opal/mca/if/linux_ipv6/if_linux_ipv6.c | 3 +- opal/mca/if/posix_ipv4/if_posix.c | 3 +- opal/mca/if/solaris_ipv6/if_solaris_ipv6.c | 5 +- opal/mca/pmix/ext1x/pmix1x.c | 3 +- opal/mca/pmix/ext1x/pmix1x_client.c | 71 +++++++++-------- opal/mca/pmix/ext1x/pmix1x_server_north.c | 3 +- opal/mca/pmix/ext1x/pmix1x_server_south.c | 13 +-- opal/mca/pmix/ext2x/ext2x.c | 19 ++--- opal/mca/pmix/ext2x/ext2x_client.c | 79 ++++++++++--------- opal/mca/pmix/ext2x/ext2x_server_north.c | 7 +- opal/mca/pmix/ext2x/ext2x_server_south.c | 13 +-- opal/mca/pmix/ext3x/ext3x.c | 21 ++--- opal/mca/pmix/ext3x/ext3x_client.c | 79 ++++++++++--------- opal/mca/pmix/ext3x/ext3x_server_north.c | 7 +- opal/mca/pmix/ext3x/ext3x_server_south.c | 17 ++-- opal/mca/pstat/test/pstat_test.c | 5 +- opal/mca/rcache/udreg/rcache_udreg_module.c | 3 +- .../netlink/reachable_netlink_module.c | 5 +- .../reachable/weighted/reachable_weighted.c | 5 +- opal/mca/shmem/mmap/shmem_mmap_module.c | 3 +- opal/test/reachable/reachable_shared.h | 3 +- opal/util/argv.c | 5 +- opal/util/basename.c | 6 +- opal/util/error.c | 5 +- opal/util/ethtool.c | 5 +- opal/util/fd.c | 3 +- opal/util/if.c | 9 ++- opal/util/info.c | 26 ++---- opal/util/info_subscriber.c | 1 - opal/util/keyval_parse.c | 5 +- opal/util/opal_getcwd.c | 7 +- opal/util/output.c | 3 +- opal/util/proc.c | 5 +- opal/win32/opal_utsname.c | 3 +- opal/win32/win_compat.h | 1 - 42 files changed, 250 insertions(+), 240 deletions(-) diff --git a/opal/mca/base/mca_base_component_repository.c b/opal/mca/base/mca_base_component_repository.c index b34f19eea0..99e217d32a 100644 --- a/opal/mca/base/mca_base_component_repository.c +++ b/opal/mca/base/mca_base_component_repository.c @@ -43,6 +43,7 @@ #include "opal/constants.h" #include "opal/class/opal_hash_table.h" #include "opal/util/basename.h" +#include "opal/util/string_copy.h" #if OPAL_HAVE_DL_SUPPORT @@ -167,12 +168,8 @@ static int process_repository_item (const char *filename, void *data) return OPAL_ERR_OUT_OF_RESOURCE; } - /* strncpy does not guarantee a \0 */ - ri->ri_type[MCA_BASE_MAX_TYPE_NAME_LEN] = '\0'; - strncpy (ri->ri_type, type, MCA_BASE_MAX_TYPE_NAME_LEN); - - ri->ri_name[MCA_BASE_MAX_TYPE_NAME_LEN] = '\0'; - strncpy (ri->ri_name, name, MCA_BASE_MAX_COMPONENT_NAME_LEN); + opal_string_copy (ri->ri_type, type, MCA_BASE_MAX_TYPE_NAME_LEN); + opal_string_copy (ri->ri_name, name, MCA_BASE_MAX_COMPONENT_NAME_LEN); opal_list_append (component_list, &ri->super); diff --git a/opal/mca/btl/openib/btl_openib_ini.c b/opal/mca/btl/openib/btl_openib_ini.c index 0e1b755153..ec74193c0f 100644 --- a/opal/mca/btl/openib/btl_openib_ini.c +++ b/opal/mca/btl/openib/btl_openib_ini.c @@ -35,6 +35,7 @@ #endif #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "btl_openib.h" #include "btl_openib_lex.h" @@ -324,7 +325,7 @@ static int parse_line(parsed_section_values_t *sv) } key_buffer = tmp; } - strncpy(key_buffer, btl_openib_ini_yytext, key_buffer_len); + opal_string_copy(key_buffer, btl_openib_ini_yytext, key_buffer_len); /* The first thing we have to see is an "=" */ val = btl_openib_ini_yylex(); diff --git a/opal/mca/btl/usnic/btl_usnic_cagent.c b/opal/mca/btl/usnic/btl_usnic_cagent.c index 386aec0a26..bd9cac55e3 100644 --- a/opal/mca/btl/usnic/btl_usnic_cagent.c +++ b/opal/mca/btl/usnic/btl_usnic_cagent.c @@ -27,6 +27,7 @@ #include "opal/types.h" #include "opal/util/output.h" #include "opal/util/fd.h" +#include "opal/util/string_copy.h" #include "btl_usnic.h" #include "btl_usnic_connectivity.h" @@ -1189,7 +1190,7 @@ int opal_btl_usnic_connectivity_agent_init(void) memset(&address, 0, sizeof(struct sockaddr_un)); address.sun_family = AF_UNIX; - strncpy(address.sun_path, ipc_filename, sizeof(address.sun_path) - 1); + opal_string_copy(address.sun_path, ipc_filename, sizeof(address.sun_path)); if (bind(ipc_accept_fd, (struct sockaddr *) &address, sizeof(struct sockaddr_un)) != 0) { diff --git a/opal/mca/btl/usnic/btl_usnic_cclient.c b/opal/mca/btl/usnic/btl_usnic_cclient.c index 77615937e4..4027057d15 100644 --- a/opal/mca/btl/usnic/btl_usnic_cclient.c +++ b/opal/mca/btl/usnic/btl_usnic_cclient.c @@ -28,6 +28,7 @@ #include "opal/mca/event/event.h" #include "opal/util/output.h" #include "opal/util/fd.h" +#include "opal/util/string_copy.h" #include "btl_usnic.h" #include "btl_usnic_module.h" @@ -103,7 +104,7 @@ int opal_btl_usnic_connectivity_client_init(void) struct sockaddr_un address; memset(&address, 0, sizeof(struct sockaddr_un)); address.sun_family = AF_UNIX; - strncpy(address.sun_path, ipc_filename, sizeof(address.sun_path) - 1); + opal_string_copy(address.sun_path, ipc_filename, sizeof(address.sun_path)); int count = 0; while (1) { @@ -195,10 +196,10 @@ int opal_btl_usnic_connectivity_listen(opal_btl_usnic_module_t *module) } /* Ensure to NULL-terminate the passed strings */ - strncpy(cmd.nodename, opal_process_info.nodename, - CONNECTIVITY_NODENAME_LEN - 1); - strncpy(cmd.usnic_name, module->linux_device_name, - CONNECTIVITY_IFNAME_LEN - 1); + opal_string_copy(cmd.nodename, opal_process_info.nodename, + CONNECTIVITY_NODENAME_LEN); + opal_string_copy(cmd.usnic_name, module->linux_device_name, + CONNECTIVITY_IFNAME_LEN); if (OPAL_SUCCESS != opal_fd_write(agent_fd, sizeof(cmd), &cmd)) { OPAL_ERROR_LOG(OPAL_ERR_IN_ERRNO); @@ -255,7 +256,7 @@ int opal_btl_usnic_connectivity_ping(uint32_t src_ipv4_addr, int src_port, .max_msg_size = max_msg_size }; /* Ensure to NULL-terminate the passed string */ - strncpy(cmd.dest_nodename, dest_nodename, CONNECTIVITY_NODENAME_LEN - 1); + opal_string_copy(cmd.dest_nodename, dest_nodename, CONNECTIVITY_NODENAME_LEN); if (OPAL_SUCCESS != opal_fd_write(agent_fd, sizeof(cmd), &cmd)) { OPAL_ERROR_LOG(OPAL_ERR_IN_ERRNO); diff --git a/opal/mca/btl/usnic/btl_usnic_proc.c b/opal/mca/btl/usnic/btl_usnic_proc.c index 5b96a77a7e..bb5239d503 100644 --- a/opal/mca/btl/usnic/btl_usnic_proc.c +++ b/opal/mca/btl/usnic/btl_usnic_proc.c @@ -28,6 +28,7 @@ #include "opal/util/show_help.h" #include "opal/constants.h" #include "opal/util/bipartite_graph.h" +#include "opal/util/string_copy.h" #include "btl_usnic_compat.h" #include "btl_usnic.h" @@ -239,8 +240,8 @@ static int create_proc(opal_proc_t *opal_proc, char protostr[32]; proto = mca_btl_usnic_component.transport_protocol; memset(protostr, 0, sizeof(protostr)); - strncpy(protostr, fi_tostr(&proto, FI_TYPE_PROTOCOL), - sizeof(protostr) - 1); + opal_string_copy(protostr, fi_tostr(&proto, FI_TYPE_PROTOCOL), + sizeof(protostr)); proto = proc->proc_modex->protocol; opal_show_help("help-mpi-btl-usnic.txt", "transport mismatch", diff --git a/opal/mca/if/bsdx_ipv4/if_bsdx.c b/opal/mca/if/bsdx_ipv4/if_bsdx.c index e67f9b7f6b..f96f44b252 100644 --- a/opal/mca/if/bsdx_ipv4/if_bsdx.c +++ b/opal/mca/if/bsdx_ipv4/if_bsdx.c @@ -15,6 +15,7 @@ #include "opal/constants.h" #include "opal/util/output.h" +#include "opal/util/string_copy.h" #include "opal/mca/if/if.h" static int if_bsdx_open(void); @@ -125,7 +126,7 @@ static int if_bsdx_open(void) /* fill values into the opal_if_t */ memcpy(&a4, &(sin_addr->sin_addr), sizeof(struct in_addr)); - strncpy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE); + opal_string_copy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE); intf->if_index = opal_list_get_size(&opal_if_list) + 1; ((struct sockaddr_in*) &intf->if_addr)->sin_addr = a4; ((struct sockaddr_in*) &intf->if_addr)->sin_family = AF_INET; diff --git a/opal/mca/if/bsdx_ipv6/if_bsdx_ipv6.c b/opal/mca/if/bsdx_ipv6/if_bsdx_ipv6.c index d6cf3d6861..3044e89c97 100644 --- a/opal/mca/if/bsdx_ipv6/if_bsdx_ipv6.c +++ b/opal/mca/if/bsdx_ipv6/if_bsdx_ipv6.c @@ -11,6 +11,7 @@ #include "opal_config.h" #include "opal/constants.h" #include "opal/util/output.h" +#include "opal/util/string_copy.h" #include #ifdef HAVE_UNISTD_H @@ -198,7 +199,7 @@ static int if_bsdx_ipv6_open(void) return OPAL_ERR_OUT_OF_RESOURCE; } intf->af_family = AF_INET6; - strncpy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE); + opal_string_copy(intf->if_name, cur_ifaddrs->ifa_name, IF_NAMESIZE); intf->if_index = opal_list_get_size(&opal_if_list) + 1; ((struct sockaddr_in6*) &intf->if_addr)->sin6_addr = a6; ((struct sockaddr_in6*) &intf->if_addr)->sin6_family = AF_INET6; diff --git a/opal/mca/if/linux_ipv6/if_linux_ipv6.c b/opal/mca/if/linux_ipv6/if_linux_ipv6.c index d566eb87b0..4e979648d9 100644 --- a/opal/mca/if/linux_ipv6/if_linux_ipv6.c +++ b/opal/mca/if/linux_ipv6/if_linux_ipv6.c @@ -62,6 +62,7 @@ #include "opal/constants.h" #include "opal/util/if.h" #include "opal/util/output.h" +#include "opal/util/string_copy.h" #include "opal/mca/if/if.h" #include "opal/mca/if/base/base.h" @@ -143,7 +144,7 @@ static int if_linux_ipv6_open(void) } /* now construct the opal_if_t */ - strncpy(intf->if_name, ifname, IF_NAMESIZE); + opal_string_copy(intf->if_name, ifname, IF_NAMESIZE); intf->if_index = opal_list_get_size(&opal_if_list)+1; intf->if_kernel_index = (uint16_t) idx; ((struct sockaddr_in6*) &intf->if_addr)->sin6_addr = a6; diff --git a/opal/mca/if/posix_ipv4/if_posix.c b/opal/mca/if/posix_ipv4/if_posix.c index c50ae35c2d..0145ac8488 100644 --- a/opal/mca/if/posix_ipv4/if_posix.c +++ b/opal/mca/if/posix_ipv4/if_posix.c @@ -19,6 +19,7 @@ #include "opal/constants.h" #include "opal/util/output.h" +#include "opal/util/string_copy.h" #include "opal/mca/if/if.h" #include "opal/mca/if/base/base.h" @@ -218,7 +219,7 @@ static int if_posix_open(void) /* copy entry over into our data structure */ memset(intf->if_name, 0, sizeof(intf->if_name)); - strncpy(intf->if_name, ifr->ifr_name, sizeof(intf->if_name) - 1); + opal_string_copy(intf->if_name, ifr->ifr_name, sizeof(intf->if_name)); intf->if_flags = ifr->ifr_flags; /* every new address gets its own internal if_index */ diff --git a/opal/mca/if/solaris_ipv6/if_solaris_ipv6.c b/opal/mca/if/solaris_ipv6/if_solaris_ipv6.c index 6f71806553..0972aabef6 100644 --- a/opal/mca/if/solaris_ipv6/if_solaris_ipv6.c +++ b/opal/mca/if/solaris_ipv6/if_solaris_ipv6.c @@ -15,6 +15,7 @@ #include "opal/constants.h" #include "opal/util/output.h" +#include "opal/util/string_copy.h" #include "opal/mca/if/if.h" static int if_solaris_ipv6_open(void); @@ -96,7 +97,7 @@ static int if_solaris_ipv6_open(void) i += sizeof (*lifreq)) { lifreq = (struct lifreq *)((caddr_t)lifconf.lifc_buf + i); - strncpy (lifquery.lifr_name, lifreq->lifr_name, + opal_string_copy (lifquery.lifr_name, lifreq->lifr_name, sizeof (lifquery.lifr_name)); /* lookup kernel index */ @@ -140,7 +141,7 @@ static int if_solaris_ipv6_open(void) } intf->af_family = AF_INET6; - strncpy (intf->if_name, lifreq->lifr_name, IF_NAMESIZE); + opal_string_copy (intf->if_name, lifreq->lifr_name, IF_NAMESIZE); intf->if_index = opal_list_get_size(&opal_if_list)+1; memcpy(&intf->if_addr, my_addr, sizeof (*my_addr)); intf->if_mask = 64; diff --git a/opal/mca/pmix/ext1x/pmix1x.c b/opal/mca/pmix/ext1x/pmix1x.c index d71d35b1bf..eaac380e75 100644 --- a/opal/mca/pmix/ext1x/pmix1x.c +++ b/opal/mca/pmix/ext1x/pmix1x.c @@ -34,6 +34,7 @@ #include "opal/util/output.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "pmix1x.h" #include "opal/mca/pmix/base/base.h" @@ -124,7 +125,7 @@ static void pmix1_register_jobid(opal_jobid_t jobid, const char *nspace) } } jptr = OBJ_NEW(opal_pmix1_jobid_trkr_t); - (void)strncpy(jptr->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(jptr->nspace, nspace, PMIX_MAX_NSLEN); jptr->jobid = jobid; opal_list_append(&mca_pmix_ext1x_component.jobids, &jptr->super); } diff --git a/opal/mca/pmix/ext1x/pmix1x_client.c b/opal/mca/pmix/ext1x/pmix1x_client.c index 11d5048b17..d06bc5791a 100644 --- a/opal/mca/pmix/ext1x/pmix1x_client.c +++ b/opal/mca/pmix/ext1x/pmix1x_client.c @@ -26,6 +26,7 @@ #include "opal/util/argv.h" #include "opal/util/proc.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "pmix1x.h" @@ -134,7 +135,7 @@ int pmix1_client_init(opal_list_t *ilist) /* insert this into our list of jobids - it will be the * first, and so we'll check it first */ job = OBJ_NEW(opal_pmix1_jobid_trkr_t); - (void)strncpy(job->nspace, my_proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, my_proc.nspace, PMIX_MAX_NSLEN); job->jobid = pname.jobid; opal_list_append(&mca_pmix_ext1x_component.jobids, &job->super); @@ -199,7 +200,7 @@ int pmix1_abort(int flag, const char *msg, if (NULL == job) { return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); parray[n].rank = ptr->name.vpid; ++n; } @@ -243,11 +244,11 @@ int pmix1_store_local(const opal_process_name_t *proc, opal_value_t *val) opal_list_append(&mca_pmix_ext1x_component.values, &hack->super); return OPAL_SUCCESS; } - (void)strncpy(p.nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, job->nspace, PMIX_MAX_NSLEN); p.rank = proc->vpid; } else { /* use our name */ - (void)strncpy(p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); p.rank = OPAL_PROC_MY_NAME.vpid; } @@ -308,14 +309,14 @@ int pmix1_fence(opal_list_t *procs, int collect_data) if (NULL == job) { return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); parray[n].rank = ptr->name.vpid; ++n; } } if (collect_data) { PMIX_INFO_CONSTRUCT(&info); - (void)strncpy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); + (void)opal_string_copy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); info.value.type = PMIX_BOOL; info.value.data.flag = true; iptr = &info; @@ -370,7 +371,7 @@ int pmix1_fencenb(opal_list_t *procs, int collect_data, if (NULL == job) { return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); parray[n].rank = ptr->name.vpid; ++n; } @@ -378,7 +379,7 @@ int pmix1_fencenb(opal_list_t *procs, int collect_data, if (collect_data) { PMIX_INFO_CONSTRUCT(&info); - (void)strncpy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); + (void)opal_string_copy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); info.value.type = PMIX_BOOL; info.value.data.flag = true; iptr = &info; @@ -464,7 +465,7 @@ int pmix1_get(const opal_process_name_t *proc, const char *key, /* otherwise, we can't find it */ return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p.nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, job->nspace, PMIX_MAX_NSLEN); if (OPAL_VPID_WILDCARD == proc->vpid) { p.rank = my_proc.rank; } else { @@ -492,10 +493,10 @@ int pmix1_get(const opal_process_name_t *proc, const char *key, n=0; OPAL_LIST_FOREACH(ival, info, opal_value_t) { if (0 == strcmp(ival->key, OPAL_PMIX_IMMEDIATE)) { - (void)strncpy(pinfo[n].key, OPAL_PMIX_OPTIONAL, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, OPAL_PMIX_OPTIONAL, PMIX_MAX_KEYLEN); pmix1_value_load(&pinfo[n].value, ival); } else { - (void)strncpy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); pmix1_value_load(&pinfo[n].value, ival); } ++n; @@ -577,10 +578,10 @@ int pmix1_getnb(const opal_process_name_t *proc, const char *key, if (NULL == job) { return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->p.nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->p.nspace, job->nspace, PMIX_MAX_NSLEN); op->p.rank = proc->vpid; } else { - (void)strncpy(op->p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); op->p.rank = PMIX_RANK_WILDCARD; } @@ -589,10 +590,10 @@ int pmix1_getnb(const opal_process_name_t *proc, const char *key, n=0; OPAL_LIST_FOREACH(ival, info, opal_value_t) { if (0 == strcmp(ival->key, OPAL_PMIX_IMMEDIATE)) { - (void)strncpy(op->info[n].key, OPAL_PMIX_OPTIONAL, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, OPAL_PMIX_OPTIONAL, PMIX_MAX_KEYLEN); pmix1_value_load(&op->info[n].value, ival); } else { - (void)strncpy(op->info[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, ival->key, PMIX_MAX_KEYLEN); pmix1_value_load(&op->info[n].value, ival); } ++n; @@ -627,7 +628,7 @@ int pmix1_publish(opal_list_t *info) PMIX_INFO_CREATE(pinfo, sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); pmix1_value_load(&pinfo[n].value, iptr); ++n; } @@ -668,7 +669,7 @@ int pmix1_publishnb(opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); pmix1_value_load(&op->info[n].value, iptr); ++n; } @@ -704,14 +705,14 @@ int pmix1_lookup(opal_list_t *data, opal_list_t *info) PMIX_PDATA_CREATE(pdata, sz); n=0; OPAL_LIST_FOREACH(d, data, opal_pmix_pdata_t) { - (void)strncpy(pdata[n++].key, d->value.key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pdata[n++].key, d->value.key, PMIX_MAX_KEYLEN); } if (NULL != info && (0 < (ninfo = opal_list_get_size(info)))) { PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); pmix1_value_load(&pinfo[n].value, iptr); ++n; } @@ -746,7 +747,7 @@ int pmix1_lookup(opal_list_t *data, opal_list_t *info) } if (NULL == job) { job = OBJ_NEW(opal_pmix1_jobid_trkr_t); - (void)strncpy(job->nspace, pdata[n].proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, pdata[n].proc.nspace, PMIX_MAX_NSLEN); job->jobid = d->proc.jobid; opal_list_append(&mca_pmix_ext1x_component.jobids, &job->super); } @@ -809,7 +810,7 @@ static void lk_cbfunc(pmix_status_t status, } if (NULL == job) { job = OBJ_NEW(opal_pmix1_jobid_trkr_t); - (void)strncpy(job->nspace, data[n].proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, data[n].proc.nspace, PMIX_MAX_NSLEN); job->jobid = d->proc.jobid; opal_list_append(&mca_pmix_ext1x_component.jobids, &job->super); } @@ -859,7 +860,7 @@ int pmix1_lookupnb(char **keys, opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); pmix1_value_load(&op->info[n].value, iptr); ++n; } @@ -881,7 +882,7 @@ int pmix1_unpublish(char **keys, opal_list_t *info) PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); pmix1_value_load(&pinfo[n].value, iptr); ++n; } @@ -913,7 +914,7 @@ int pmix1_unpublishnb(char **keys, opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); pmix1_value_load(&op->info[n].value, iptr); ++n; } @@ -939,7 +940,7 @@ int pmix1_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(info, job_info, opal_value_t) { - (void)strncpy(pinfo[n].key, info->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, info->key, PMIX_MAX_KEYLEN); pmix1_value_load(&pinfo[n].value, info); ++n; } @@ -958,7 +959,7 @@ int pmix1_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) PMIX_INFO_CREATE(papps[n].info, papps[n].ninfo); m=0; OPAL_LIST_FOREACH(info, &app->info, opal_value_t) { - (void)strncpy(papps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(papps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); pmix1_value_load(&papps[n].info[m].value, info); ++m; } @@ -979,7 +980,7 @@ int pmix1_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) } /* add this to our jobid tracker */ job = OBJ_NEW(opal_pmix1_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = *jobid; opal_list_append(&mca_pmix_ext1x_component.jobids, &job->super); } @@ -1012,7 +1013,7 @@ static void spcbfunc(pmix_status_t status, } /* add this to our jobid tracker */ job = OBJ_NEW(opal_pmix1_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = jobid; opal_list_append(&mca_pmix_ext1x_component.jobids, &job->super); } @@ -1039,7 +1040,7 @@ int pmix1_spawnnb(opal_list_t *job_info, opal_list_t *apps, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(info, job_info, opal_value_t) { - (void)strncpy(op->info[n].key, info->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, info->key, PMIX_MAX_KEYLEN); pmix1_value_load(&op->info[n].value, info); ++n; } @@ -1058,7 +1059,7 @@ int pmix1_spawnnb(opal_list_t *job_info, opal_list_t *apps, PMIX_INFO_CREATE(op->apps[n].info, op->apps[n].ninfo); m=0; OPAL_LIST_FOREACH(info, &app->info, opal_value_t) { - (void)strncpy(op->apps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->apps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); pmix1_value_load(&op->apps[n].info[m].value, info); ++m; } @@ -1102,7 +1103,7 @@ int pmix1_connect(opal_list_t *procs) OPAL_ERROR_LOG(OPAL_ERR_NOT_FOUND); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); if (OPAL_VPID_WILDCARD == ptr->name.vpid) { parray[n].rank = PMIX_RANK_WILDCARD; } else { @@ -1147,7 +1148,7 @@ int pmix1_connectnb(opal_list_t *procs, * corresponding nspace */ OPAL_LIST_FOREACH(job, &mca_pmix_ext1x_component.jobids, opal_pmix1_jobid_trkr_t) { if (job->jobid == ptr->name.jobid) { - (void)strncpy(op->procs[n].nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->procs[n].nspace, job->nspace, PMIX_MAX_NSLEN); break; } } @@ -1186,7 +1187,7 @@ int pmix1_disconnect(opal_list_t *procs) * corresponding nspace */ OPAL_LIST_FOREACH(job, &mca_pmix_ext1x_component.jobids, opal_pmix1_jobid_trkr_t) { if (job->jobid == ptr->name.jobid) { - (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); break; } } @@ -1234,7 +1235,7 @@ int pmix1_disconnectnb(opal_list_t *procs, * corresponding nspace */ OPAL_LIST_FOREACH(job, &mca_pmix_ext1x_component.jobids, opal_pmix1_jobid_trkr_t) { if (job->jobid == ptr->name.jobid) { - (void)strncpy(op->procs[n].nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->procs[n].nspace, job->nspace, PMIX_MAX_NSLEN); break; } } @@ -1305,7 +1306,7 @@ int pmix1_resolve_peers(const char *nodename, opal_jobid_t jobid, } if (NULL == job) { job = OBJ_NEW(opal_pmix1_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = jobid; opal_list_append(&mca_pmix_ext1x_component.jobids, &job->super); } diff --git a/opal/mca/pmix/ext1x/pmix1x_server_north.c b/opal/mca/pmix/ext1x/pmix1x_server_north.c index def0ac1b50..61791427c1 100644 --- a/opal/mca/pmix/ext1x/pmix1x_server_north.c +++ b/opal/mca/pmix/ext1x/pmix1x_server_north.c @@ -34,6 +34,7 @@ #include "opal/util/output.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "pmix1x.h" @@ -419,7 +420,7 @@ static void opal_lkupcbfunc(int status, /* convert the jobid */ (void)opal_snprintf_jobid(d[n].proc.nspace, PMIX_MAX_NSLEN, p->proc.jobid); d[n].proc.rank = p->proc.vpid; - (void)strncpy(d[n].key, p->value.key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(d[n].key, p->value.key, PMIX_MAX_KEYLEN); pmix1_value_load(&d[n].value, &p->value); } } diff --git a/opal/mca/pmix/ext1x/pmix1x_server_south.c b/opal/mca/pmix/ext1x/pmix1x_server_south.c index d087f58596..189476a326 100644 --- a/opal/mca/pmix/ext1x/pmix1x_server_south.c +++ b/opal/mca/pmix/ext1x/pmix1x_server_south.c @@ -35,6 +35,7 @@ #include "opal/util/output.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "pmix1x.h" @@ -143,7 +144,7 @@ int pmix1_server_init(opal_pmix_server_module_t *module, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); pmix1_value_load(&pinfo[n].value, kv); ++n; } @@ -242,7 +243,7 @@ int pmix1_server_register_nspace(opal_jobid_t jobid, /* store this job in our list of known nspaces */ job = OBJ_NEW(opal_pmix1_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = jobid; opal_list_append(&mca_pmix_ext1x_component.jobids, &job->super); @@ -251,7 +252,7 @@ int pmix1_server_register_nspace(opal_jobid_t jobid, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); if (0 == strcmp(kv->key, OPAL_PMIX_PROC_DATA)) { pinfo[n].value.type = PMIX_INFO_ARRAY; /* the value contains a list of values - convert @@ -264,7 +265,7 @@ int pmix1_server_register_nspace(opal_jobid_t jobid, pinfo[n].value.data.array.size = szmap; m = 0; OPAL_LIST_FOREACH(k2, pmapinfo, opal_value_t) { - (void)strncpy(pmap[m].key, k2->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pmap[m].key, k2->key, PMIX_MAX_KEYLEN); pmix1_value_load(&pmap[m].value, k2); ++m; } @@ -352,7 +353,7 @@ void pmix1_server_deregister_client(const opal_process_name_t *proc, OPAL_LIST_FOREACH(jptr, &mca_pmix_ext1x_component.jobids, opal_pmix1_jobid_trkr_t) { if (jptr->jobid == proc->jobid) { /* found it - tell the server to deregister */ - (void)strncpy(p.nspace, jptr->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, jptr->nspace, PMIX_MAX_NSLEN); p.rank = proc->vpid; PMIx_server_deregister_client(&p); return; @@ -433,7 +434,7 @@ int pmix1_server_notify_error(int status, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); pmix1_value_load(&pinfo[n].value, kv); } } else { diff --git a/opal/mca/pmix/ext2x/ext2x.c b/opal/mca/pmix/ext2x/ext2x.c index 7e0803a9e5..ce8324978f 100644 --- a/opal/mca/pmix/ext2x/ext2x.c +++ b/opal/mca/pmix/ext2x/ext2x.c @@ -38,6 +38,7 @@ #include "opal/util/output.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "ext2x.h" #include "opal/mca/pmix/base/base.h" @@ -175,7 +176,7 @@ static void ext2x_register_jobid(opal_jobid_t jobid, const char *nspace) } } jptr = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(jptr->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(jptr->nspace, nspace, PMIX_MAX_NSLEN); jptr->jobid = jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &jptr->super); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -207,7 +208,7 @@ static void return_local_event_hdlr(int status, opal_list_t *results, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(kv, cd->info, opal_value_t) { - (void)strncpy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->info[n].value, kv); ++n; } @@ -771,7 +772,7 @@ void ext2x_value_load(pmix_value_t *v, found = false; OPAL_LIST_FOREACH(job, &mca_pmix_ext2x_component.jobids, opal_ext2x_jobid_trkr_t) { if (job->jobid == kv->data.name.jobid) { - (void)strncpy(v->data.proc->nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(v->data.proc->nspace, job->nspace, PMIX_MAX_NSLEN); found = true; break; } @@ -824,7 +825,7 @@ void ext2x_value_load(pmix_value_t *v, v->data.darray->array = info; n=0; OPAL_LIST_FOREACH(val, list, opal_value_t) { - (void)strncpy(info[n].key, val->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(info[n].key, val->key, PMIX_MAX_KEYLEN); ext2x_value_load(&info[n].value, val); ++n; } @@ -1078,7 +1079,7 @@ static void register_handler(opal_list_t *event_codes, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->info[n].value, kv); ++n; } @@ -1177,7 +1178,7 @@ static int notify_event(int status, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p.nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, nsptr, PMIX_MAX_NSLEN); p.rank = ext2x_convert_opalrank(source->vpid); pptr = &p; } @@ -1191,7 +1192,7 @@ static int notify_event(int status, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); /* little dicey here as we need to convert a status, if * provided, and it will be an int coming down to us */ if (0 == strcmp(kv->key, OPAL_PMIX_JOB_TERM_STATUS)) { @@ -1302,7 +1303,7 @@ static void ext2x_query(opal_list_t *queries, PMIX_INFO_CREATE(cd->queries[n].qualifiers, cd->queries[n].nqual); nq = 0; OPAL_LIST_FOREACH(ival, &q->qualifiers, opal_value_t) { - (void)strncpy(cd->queries[n].qualifiers[nq].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(cd->queries[n].qualifiers[nq].key, ival->key, PMIX_MAX_KEYLEN); ext2x_value_load(&cd->queries[n].qualifiers[nq].value, ival); ++nq; } @@ -1365,7 +1366,7 @@ static void ext2x_log(opal_list_t *info, PMIX_INFO_CREATE(cd->info, cd->ninfo); n=0; OPAL_LIST_FOREACH(ival, info, opal_value_t) { - (void)strncpy(cd->info[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(cd->info[n].key, ival->key, PMIX_MAX_KEYLEN); ext2x_value_load(&cd->info[n].value, ival); ++n; } diff --git a/opal/mca/pmix/ext2x/ext2x_client.c b/opal/mca/pmix/ext2x/ext2x_client.c index 43c711f584..e244d124c0 100644 --- a/opal/mca/pmix/ext2x/ext2x_client.c +++ b/opal/mca/pmix/ext2x/ext2x_client.c @@ -32,6 +32,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "ext2x.h" @@ -90,7 +91,7 @@ int ext2x_client_init(opal_list_t *ilist) PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(ival, ilist, opal_value_t) { - (void)strncpy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pinfo[n].value, ival); ++n; } @@ -131,7 +132,7 @@ int ext2x_client_init(opal_list_t *ilist) /* insert this into our list of jobids - it will be the * first, and so we'll check it first */ job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, my_proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, my_proc.nspace, PMIX_MAX_NSLEN); job->jobid = pname.jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); @@ -210,13 +211,13 @@ int ext2x_tool_init(opal_list_t *info) PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(val, info, opal_value_t) { - (void)strncpy(pinfo[n].key, val->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, val->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pinfo[n].value, val); ++n; /* check to see if our name is being given from above */ if (0 == strcmp(val->key, OPAL_PMIX_TOOL_NSPACE)) { opal_convert_string_to_jobid(&pname.jobid, val->data.string); - (void)strncpy(my_proc.nspace, val->data.string, PMIX_MAX_NSLEN); + (void)opal_string_copy(my_proc.nspace, val->data.string, PMIX_MAX_NSLEN); } else if (0 == strcmp(val->key, OPAL_PMIX_TOOL_RANK)) { pname.vpid = val->data.name.vpid; my_proc.rank = pname.vpid; @@ -255,7 +256,7 @@ int ext2x_tool_init(opal_list_t *info) /* insert this into our list of jobids - it will be the * first, and so we'll check it first */ job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, my_proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, my_proc.nspace, PMIX_MAX_NSLEN); job->jobid = pname.jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); @@ -349,7 +350,7 @@ int ext2x_abort(int flag, const char *msg, PMIX_PROC_FREE(parray, cnt); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); parray[n].rank = ext2x_convert_opalrank(ptr->name.vpid); ++n; } @@ -390,11 +391,11 @@ int ext2x_store_local(const opal_process_name_t *proc, opal_value_t *val) OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); nsptr = job->nspace; } - (void)strncpy(p.nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, nsptr, PMIX_MAX_NSLEN); p.rank = ext2x_convert_opalrank(proc->vpid); } else { /* use our name */ - (void)strncpy(p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); p.rank = ext2x_convert_opalrank(OPAL_PROC_MY_NAME.vpid); } @@ -462,7 +463,7 @@ int ext2x_fence(opal_list_t *procs, int collect_data) OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); parray[n].rank = ext2x_convert_opalrank(ptr->name.vpid); ++n; } @@ -471,7 +472,7 @@ int ext2x_fence(opal_list_t *procs, int collect_data) if (collect_data) { PMIX_INFO_CONSTRUCT(&info); - (void)strncpy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); + (void)opal_string_copy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); info.value.type = PMIX_BOOL; info.value.data.flag = true; iptr = &info; @@ -522,7 +523,7 @@ int ext2x_fencenb(opal_list_t *procs, int collect_data, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); parray[n].rank = ext2x_convert_opalrank(ptr->name.vpid); ++n; } @@ -618,14 +619,14 @@ int ext2x_get(const opal_process_name_t *proc, const char *key, *val = NULL; if (NULL == proc) { - (void)strncpy(p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); p.rank = ext2x_convert_rank(PMIX_RANK_WILDCARD); } else { if (NULL == (nsptr = ext2x_convert_jobid(proc->jobid))) { OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p.nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, nsptr, PMIX_MAX_NSLEN); p.rank = ext2x_convert_opalrank(proc->vpid); } OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -634,7 +635,7 @@ int ext2x_get(const opal_process_name_t *proc, const char *key, PMIX_INFO_CREATE(pinfo, sz); n=0; OPAL_LIST_FOREACH(ival, info, opal_value_t) { - (void)strncpy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pinfo[n].value, ival); ++n; } @@ -739,14 +740,14 @@ int ext2x_getnb(const opal_process_name_t *proc, const char *key, op->nspace = strdup(key); } if (NULL == proc) { - (void)strncpy(op->p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); op->p.rank = ext2x_convert_rank(PMIX_RANK_WILDCARD); } else { if (NULL == (nsptr = ext2x_convert_jobid(proc->jobid))) { OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->p.nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->p.nspace, nsptr, PMIX_MAX_NSLEN); op->p.rank = ext2x_convert_opalrank(proc->vpid); } OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -755,7 +756,7 @@ int ext2x_getnb(const opal_process_name_t *proc, const char *key, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(val, info, opal_value_t) { - (void)strncpy(op->info[n].key, val->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, val->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->info[n].value, val); ++n; } @@ -796,7 +797,7 @@ int ext2x_publish(opal_list_t *info) PMIX_INFO_CREATE(pinfo, sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pinfo[n].value, iptr); ++n; } @@ -844,7 +845,7 @@ int ext2x_publishnb(opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->info[n].value, iptr); ++n; } @@ -882,7 +883,7 @@ int ext2x_lookup(opal_list_t *data, opal_list_t *info) PMIX_PDATA_CREATE(pdata, cnt); n = 0; OPAL_LIST_FOREACH(d, data, opal_pmix_pdata_t) { - (void)strncpy(pdata[n].key, d->value.key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pdata[n].key, d->value.key, PMIX_MAX_KEYLEN); ++n; } @@ -890,7 +891,7 @@ int ext2x_lookup(opal_list_t *data, opal_list_t *info) PMIX_INFO_CREATE(pinfo, sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pinfo[n].value, iptr); ++n; } @@ -921,7 +922,7 @@ int ext2x_lookup(opal_list_t *data, opal_list_t *info) } if (NULL == job) { job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, pdata[n].proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, pdata[n].proc.nspace, PMIX_MAX_NSLEN); job->jobid = d->proc.jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); } @@ -983,7 +984,7 @@ static void lk_cbfunc(pmix_status_t status, } if (NULL == job) { job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, data[n].proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, data[n].proc.nspace, PMIX_MAX_NSLEN); job->jobid = d->proc.jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); } @@ -1039,7 +1040,7 @@ int ext2x_lookupnb(char **keys, opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->info[n].value, iptr); ++n; } @@ -1067,7 +1068,7 @@ int ext2x_unpublish(char **keys, opal_list_t *info) PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pinfo[n].value, iptr); ++n; } @@ -1106,7 +1107,7 @@ int ext2x_unpublishnb(char **keys, opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->info[n].value, iptr); ++n; } @@ -1141,7 +1142,7 @@ int ext2x_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) PMIX_INFO_CREATE(info, ninfo); n=0; OPAL_LIST_FOREACH(ival, job_info, opal_value_t) { - (void)strncpy(info[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(info[n].key, ival->key, PMIX_MAX_KEYLEN); ext2x_value_load(&info[n].value, ival); ++n; } @@ -1166,7 +1167,7 @@ int ext2x_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) PMIX_INFO_CREATE(papps[n].info, papps[n].ninfo); m=0; OPAL_LIST_FOREACH(ival, &app->info, opal_value_t) { - (void)strncpy(papps[n].info[m].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(papps[n].info[m].key, ival->key, PMIX_MAX_KEYLEN); ext2x_value_load(&papps[n].info[m].value, ival); ++m; } @@ -1188,7 +1189,7 @@ int ext2x_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) } /* add this to our jobid tracker */ job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = *jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -1222,7 +1223,7 @@ static void spcbfunc(pmix_status_t status, } /* add this to our jobid tracker */ job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -1257,7 +1258,7 @@ int ext2x_spawnnb(opal_list_t *job_info, opal_list_t *apps, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(info, job_info, opal_value_t) { - (void)strncpy(op->info[n].key, info->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, info->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->info[n].value, info); ++n; } @@ -1279,7 +1280,7 @@ int ext2x_spawnnb(opal_list_t *job_info, opal_list_t *apps, PMIX_INFO_CREATE(op->apps[n].info, op->apps[n].ninfo); m=0; OPAL_LIST_FOREACH(info, &app->info, opal_value_t) { - (void)strncpy(op->apps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->apps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->apps[n].info[m].value, info); ++m; } @@ -1325,7 +1326,7 @@ int ext2x_connect(opal_list_t *procs) OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p[n].nspace, nsptr, PMIX_MAX_NSLEN); p[n].rank = ext2x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1377,7 +1378,7 @@ int ext2x_connectnb(opal_list_t *procs, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); op->procs[n].rank = ext2x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1423,7 +1424,7 @@ int ext2x_disconnect(opal_list_t *procs) OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p[n].nspace, nsptr, PMIX_MAX_NSLEN); p[n].rank = ext2x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1475,7 +1476,7 @@ int ext2x_disconnectnb(opal_list_t *procs, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); op->procs[n].rank = ext2x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1534,7 +1535,7 @@ int ext2x_resolve_peers(const char *nodename, /* if we don't already have it, add this to our jobid tracker */ if (NULL == ext2x_convert_jobid(nm->name.jobid)) { job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, array[n].nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, array[n].nspace, PMIX_MAX_NSLEN); job->jobid = nm->name.jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); } @@ -1635,7 +1636,7 @@ int ext2x_job_control(opal_list_t *targets, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); op->procs[n].rank = ext2x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1646,7 +1647,7 @@ int ext2x_job_control(opal_list_t *targets, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(iptr, directives, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); ext2x_value_load(&op->info[n].value, iptr); ++n; } diff --git a/opal/mca/pmix/ext2x/ext2x_server_north.c b/opal/mca/pmix/ext2x/ext2x_server_north.c index 0fe3935b1f..be406eb6bf 100644 --- a/opal/mca/pmix/ext2x/ext2x_server_north.c +++ b/opal/mca/pmix/ext2x/ext2x_server_north.c @@ -35,6 +35,7 @@ #include "opal/util/output.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "ext2x.h" @@ -493,7 +494,7 @@ static void opal_lkupcbfunc(int status, /* convert the jobid */ (void)opal_snprintf_jobid(d[n].proc.nspace, PMIX_MAX_NSLEN, p->proc.jobid); d[n].proc.rank = ext2x_convert_opalrank(p->proc.vpid); - (void)strncpy(d[n].key, p->value.key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(d[n].key, p->value.key, PMIX_MAX_KEYLEN); ext2x_value_load(&d[n].value, &p->value); } } @@ -928,7 +929,7 @@ static void info_cbfunc(int status, PMIX_INFO_CREATE(pcaddy->info, pcaddy->ninfo); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pcaddy->info[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pcaddy->info[n].key, kv->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pcaddy->info[n].value, kv); } } @@ -1025,7 +1026,7 @@ static void toolcbfunc(int status, p.rank = ext2x_convert_opalrank(proc.vpid); /* store this job in our list of known nspaces */ job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, p.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, p.nspace, PMIX_MAX_NSLEN); job->jobid = proc.jobid; OPAL_PMIX_ACQUIRE_THREAD(&opal_pmix_base.lock); opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); diff --git a/opal/mca/pmix/ext2x/ext2x_server_south.c b/opal/mca/pmix/ext2x/ext2x_server_south.c index 3431713011..36cc04af81 100644 --- a/opal/mca/pmix/ext2x/ext2x_server_south.c +++ b/opal/mca/pmix/ext2x/ext2x_server_south.c @@ -39,6 +39,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "ext2x.h" @@ -122,7 +123,7 @@ int ext2x_server_init(opal_pmix_server_module_t *module, n = 0; if (NULL != info) { OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pinfo[n].value, kv); ++n; } @@ -259,7 +260,7 @@ int ext2x_server_register_nspace(opal_jobid_t jobid, /* store this job in our list of known nspaces */ job = OBJ_NEW(opal_ext2x_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = jobid; opal_list_append(&mca_pmix_ext2x_component.jobids, &job->super); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -269,7 +270,7 @@ int ext2x_server_register_nspace(opal_jobid_t jobid, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); if (0 == strcmp(kv->key, OPAL_PMIX_PROC_DATA)) { pinfo[n].value.type = PMIX_DATA_ARRAY; /* the value contains a list of values - convert @@ -284,7 +285,7 @@ int ext2x_server_register_nspace(opal_jobid_t jobid, pinfo[n].value.data.darray->size = szmap; m = 0; OPAL_LIST_FOREACH(k2, pmapinfo, opal_value_t) { - (void)strncpy(pmap[m].key, k2->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pmap[m].key, k2->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pmap[m].value, k2); ++m; } @@ -416,7 +417,7 @@ void ext2x_server_deregister_client(const opal_process_name_t *proc, OPAL_LIST_FOREACH(jptr, &mca_pmix_ext2x_component.jobids, opal_ext2x_jobid_trkr_t) { if (jptr->jobid == proc->jobid) { /* found it - tell the server to deregister */ - (void)strncpy(p.nspace, jptr->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, jptr->nspace, PMIX_MAX_NSLEN); p.rank = ext2x_convert_opalrank(proc->vpid); OPAL_PMIX_CONSTRUCT_LOCK(&lock); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -524,7 +525,7 @@ int ext2x_server_notify_event(int status, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); ext2x_value_load(&pinfo[n].value, kv); ++n; } diff --git a/opal/mca/pmix/ext3x/ext3x.c b/opal/mca/pmix/ext3x/ext3x.c index ef2aa6fc8f..51edf9e11e 100644 --- a/opal/mca/pmix/ext3x/ext3x.c +++ b/opal/mca/pmix/ext3x/ext3x.c @@ -41,6 +41,7 @@ #include "opal/util/output.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "pmix3x.h" #include "opal/mca/pmix/base/base.h" @@ -184,7 +185,7 @@ static void pmix3x_register_jobid(opal_jobid_t jobid, const char *nspace) } } jptr = OBJ_NEW(opal_pmix3x_jobid_trkr_t); - (void)strncpy(jptr->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(jptr->nspace, nspace, PMIX_MAX_NSLEN); jptr->jobid = jobid; opal_list_append(&mca_pmix_pmix3x_component.jobids, &jptr->super); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -216,7 +217,7 @@ static void return_local_event_hdlr(int status, opal_list_t *results, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(kv, cd->info, opal_value_t) { - (void)strncpy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); pmix3x_value_load(&op->info[n].value, kv); ++n; } @@ -844,7 +845,7 @@ void pmix3x_value_load(pmix_value_t *v, found = false; OPAL_LIST_FOREACH(job, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { if (job->jobid == kv->data.name.jobid) { - (void)strncpy(v->data.proc->nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(v->data.proc->nspace, job->nspace, PMIX_MAX_NSLEN); found = true; break; } @@ -905,7 +906,7 @@ void pmix3x_value_load(pmix_value_t *v, n=0; OPAL_LIST_FOREACH(val, list, opal_value_t) { if (NULL != val->key) { - (void)strncpy(info[n].key, val->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(info[n].key, val->key, PMIX_MAX_KEYLEN); } pmix3x_value_load(&info[n].value, val); ++n; @@ -921,7 +922,7 @@ void pmix3x_value_load(pmix_value_t *v, found = false; OPAL_LIST_FOREACH(job, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { if (job->jobid == kv->data.pinfo.name.jobid) { - (void)strncpy(v->data.pinfo->proc.nspace, job->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(v->data.pinfo->proc.nspace, job->nspace, PMIX_MAX_NSLEN); found = true; break; } @@ -1303,7 +1304,7 @@ static void register_handler(opal_list_t *event_codes, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); pmix3x_value_load(&op->info[n].value, kv); ++n; } @@ -1402,7 +1403,7 @@ static int notify_event(int status, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p.nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, nsptr, PMIX_MAX_NSLEN); p.rank = pmix3x_convert_opalrank(source->vpid); pptr = &p; } @@ -1416,7 +1417,7 @@ static int notify_event(int status, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, kv->key, PMIX_MAX_KEYLEN); /* little dicey here as we need to convert a status, if * provided, and it will be an int coming down to us */ if (0 == strcmp(kv->key, OPAL_PMIX_JOB_TERM_STATUS)) { @@ -1528,7 +1529,7 @@ static void pmix3x_query(opal_list_t *queries, PMIX_INFO_CREATE(cd->queries[n].qualifiers, cd->queries[n].nqual); nq = 0; OPAL_LIST_FOREACH(ival, &q->qualifiers, opal_value_t) { - (void)strncpy(cd->queries[n].qualifiers[nq].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(cd->queries[n].qualifiers[nq].key, ival->key, PMIX_MAX_KEYLEN); pmix3x_value_load(&cd->queries[n].qualifiers[nq].value, ival); ++nq; } @@ -1591,7 +1592,7 @@ static void pmix3x_log(opal_list_t *info, PMIX_INFO_CREATE(cd->info, cd->ninfo); n=0; OPAL_LIST_FOREACH(ival, info, opal_value_t) { - (void)strncpy(cd->info[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(cd->info[n].key, ival->key, PMIX_MAX_KEYLEN); pmix3x_value_load(&cd->info[n].value, ival); ++n; } diff --git a/opal/mca/pmix/ext3x/ext3x_client.c b/opal/mca/pmix/ext3x/ext3x_client.c index 78c500ad5f..a10cc3257f 100644 --- a/opal/mca/pmix/ext3x/ext3x_client.c +++ b/opal/mca/pmix/ext3x/ext3x_client.c @@ -32,6 +32,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "ext3x.h" @@ -89,7 +90,7 @@ int ext3x_client_init(opal_list_t *ilist) PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(ival, ilist, opal_value_t) { - (void)strncpy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, ival); ++n; } @@ -135,7 +136,7 @@ int ext3x_client_init(opal_list_t *ilist) /* insert this into our list of jobids - it will be the * first, and so we'll check it first */ job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); job->jobid = pname.jobid; opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); @@ -214,13 +215,13 @@ int ext3x_tool_init(opal_list_t *info) PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(val, info, opal_value_t) { - (void)strncpy(pinfo[n].key, val->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, val->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, val); ++n; /* check to see if our name is being given from above */ if (0 == strcmp(val->key, OPAL_PMIX_TOOL_NSPACE)) { opal_convert_string_to_jobid(&pname.jobid, val->data.string); - (void)strncpy(mca_pmix_ext3x_component.myproc.nspace, val->data.string, PMIX_MAX_NSLEN); + (void)opal_string_copy(mca_pmix_ext3x_component.myproc.nspace, val->data.string, PMIX_MAX_NSLEN); } else if (0 == strcmp(val->key, OPAL_PMIX_TOOL_RANK)) { pname.vpid = val->data.name.vpid; mca_pmix_ext3x_component.myproc.rank = pname.vpid; @@ -259,7 +260,7 @@ int ext3x_tool_init(opal_list_t *info) /* insert this into our list of jobids - it will be the * first, and so we'll check it first */ job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); job->jobid = pname.jobid; opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); @@ -353,7 +354,7 @@ int ext3x_abort(int flag, const char *msg, PMIX_PROC_FREE(parray, cnt); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); parray[n].rank = ext3x_convert_opalrank(ptr->name.vpid); ++n; } @@ -394,11 +395,11 @@ int ext3x_store_local(const opal_process_name_t *proc, opal_value_t *val) OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); nsptr = job->nspace; } - (void)strncpy(p.nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, nsptr, PMIX_MAX_NSLEN); p.rank = ext3x_convert_opalrank(proc->vpid); } else { /* use our name */ - (void)strncpy(p.nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); p.rank = ext3x_convert_opalrank(OPAL_PROC_MY_NAME.vpid); } @@ -467,7 +468,7 @@ int ext3x_fence(opal_list_t *procs, int collect_data) OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); parray[n].rank = ext3x_convert_opalrank(ptr->name.vpid); ++n; } @@ -476,7 +477,7 @@ int ext3x_fence(opal_list_t *procs, int collect_data) if (collect_data) { PMIX_INFO_CONSTRUCT(&info); - (void)strncpy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); + (void)opal_string_copy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); info.value.type = PMIX_BOOL; info.value.data.flag = true; iptr = &info; @@ -527,7 +528,7 @@ int ext3x_fencenb(opal_list_t *procs, int collect_data, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(parray[n].nspace, nsptr, PMIX_MAX_NSLEN); parray[n].rank = ext3x_convert_opalrank(ptr->name.vpid); ++n; } @@ -623,14 +624,14 @@ int ext3x_get(const opal_process_name_t *proc, const char *key, *val = NULL; if (NULL == proc) { - (void)strncpy(p.nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); p.rank = ext3x_convert_rank(PMIX_RANK_WILDCARD); } else { if (NULL == (nsptr = ext3x_convert_jobid(proc->jobid))) { OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p.nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, nsptr, PMIX_MAX_NSLEN); p.rank = ext3x_convert_opalrank(proc->vpid); } OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -639,7 +640,7 @@ int ext3x_get(const opal_process_name_t *proc, const char *key, PMIX_INFO_CREATE(pinfo, sz); n=0; OPAL_LIST_FOREACH(ival, info, opal_value_t) { - (void)strncpy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, ival); ++n; } @@ -744,14 +745,14 @@ int ext3x_getnb(const opal_process_name_t *proc, const char *key, op->nspace = strdup(key); } if (NULL == proc) { - (void)strncpy(op->p.nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->p.nspace, mca_pmix_ext3x_component.myproc.nspace, PMIX_MAX_NSLEN); op->p.rank = ext3x_convert_rank(PMIX_RANK_WILDCARD); } else { if (NULL == (nsptr = ext3x_convert_jobid(proc->jobid))) { OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->p.nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->p.nspace, nsptr, PMIX_MAX_NSLEN); op->p.rank = ext3x_convert_opalrank(proc->vpid); } OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -760,7 +761,7 @@ int ext3x_getnb(const opal_process_name_t *proc, const char *key, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(val, info, opal_value_t) { - (void)strncpy(op->info[n].key, val->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, val->key, PMIX_MAX_KEYLEN); ext3x_value_load(&op->info[n].value, val); ++n; } @@ -801,7 +802,7 @@ int ext3x_publish(opal_list_t *info) PMIX_INFO_CREATE(pinfo, sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, iptr); ++n; } @@ -849,7 +850,7 @@ int ext3x_publishnb(opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); ext3x_value_load(&op->info[n].value, iptr); ++n; } @@ -887,7 +888,7 @@ int ext3x_lookup(opal_list_t *data, opal_list_t *info) PMIX_PDATA_CREATE(pdata, cnt); n = 0; OPAL_LIST_FOREACH(d, data, opal_pmix_pdata_t) { - (void)strncpy(pdata[n].key, d->value.key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pdata[n].key, d->value.key, PMIX_MAX_KEYLEN); ++n; } @@ -895,7 +896,7 @@ int ext3x_lookup(opal_list_t *data, opal_list_t *info) PMIX_INFO_CREATE(pinfo, sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, iptr); ++n; } @@ -926,7 +927,7 @@ int ext3x_lookup(opal_list_t *data, opal_list_t *info) } if (NULL == job) { job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, pdata[n].proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, pdata[n].proc.nspace, PMIX_MAX_NSLEN); job->jobid = d->proc.jobid; opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); } @@ -988,7 +989,7 @@ static void lk_cbfunc(pmix_status_t status, } if (NULL == job) { job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, data[n].proc.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, data[n].proc.nspace, PMIX_MAX_NSLEN); job->jobid = d->proc.jobid; opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); } @@ -1044,7 +1045,7 @@ int ext3x_lookupnb(char **keys, opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); ext3x_value_load(&op->info[n].value, iptr); ++n; } @@ -1072,7 +1073,7 @@ int ext3x_unpublish(char **keys, opal_list_t *info) PMIX_INFO_CREATE(pinfo, ninfo); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, iptr); ++n; } @@ -1111,7 +1112,7 @@ int ext3x_unpublishnb(char **keys, opal_list_t *info, PMIX_INFO_CREATE(op->info, op->sz); n=0; OPAL_LIST_FOREACH(iptr, info, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); ext3x_value_load(&op->info[n].value, iptr); ++n; } @@ -1146,7 +1147,7 @@ int ext3x_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) PMIX_INFO_CREATE(info, ninfo); n=0; OPAL_LIST_FOREACH(ival, job_info, opal_value_t) { - (void)strncpy(info[n].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(info[n].key, ival->key, PMIX_MAX_KEYLEN); ext3x_value_load(&info[n].value, ival); ++n; } @@ -1171,7 +1172,7 @@ int ext3x_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) PMIX_INFO_CREATE(papps[n].info, papps[n].ninfo); m=0; OPAL_LIST_FOREACH(ival, &app->info, opal_value_t) { - (void)strncpy(papps[n].info[m].key, ival->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(papps[n].info[m].key, ival->key, PMIX_MAX_KEYLEN); ext3x_value_load(&papps[n].info[m].value, ival); ++m; } @@ -1193,7 +1194,7 @@ int ext3x_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) } /* add this to our jobid tracker */ job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = *jobid; opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -1227,7 +1228,7 @@ static void spcbfunc(pmix_status_t status, } /* add this to our jobid tracker */ job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = jobid; opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -1262,7 +1263,7 @@ int ext3x_spawnnb(opal_list_t *job_info, opal_list_t *apps, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(info, job_info, opal_value_t) { - (void)strncpy(op->info[n].key, info->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, info->key, PMIX_MAX_KEYLEN); ext3x_value_load(&op->info[n].value, info); ++n; } @@ -1284,7 +1285,7 @@ int ext3x_spawnnb(opal_list_t *job_info, opal_list_t *apps, PMIX_INFO_CREATE(op->apps[n].info, op->apps[n].ninfo); m=0; OPAL_LIST_FOREACH(info, &app->info, opal_value_t) { - (void)strncpy(op->apps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->apps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); ext3x_value_load(&op->apps[n].info[m].value, info); ++m; } @@ -1330,7 +1331,7 @@ int ext3x_connect(opal_list_t *procs) OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p[n].nspace, nsptr, PMIX_MAX_NSLEN); p[n].rank = ext3x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1382,7 +1383,7 @@ int ext3x_connectnb(opal_list_t *procs, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); op->procs[n].rank = ext3x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1427,7 +1428,7 @@ int ext3x_disconnect(opal_list_t *procs) OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(p[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(p[n].nspace, nsptr, PMIX_MAX_NSLEN); p[n].rank = ext3x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1479,7 +1480,7 @@ int ext3x_disconnectnb(opal_list_t *procs, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); op->procs[n].rank = ext3x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1538,7 +1539,7 @@ int ext3x_resolve_peers(const char *nodename, /* if we don't already have it, add this to our jobid tracker */ if (NULL == ext3x_convert_jobid(nm->name.jobid)) { job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, array[n].nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, array[n].nspace, PMIX_MAX_NSLEN); job->jobid = nm->name.jobid; opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); } @@ -1639,7 +1640,7 @@ int ext3x_job_control(opal_list_t *targets, OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); return OPAL_ERR_NOT_FOUND; } - (void)strncpy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); + (void)opal_string_copy(op->procs[n].nspace, nsptr, PMIX_MAX_NSLEN); op->procs[n].rank = ext3x_convert_opalrank(ptr->name.vpid); ++n; } @@ -1650,7 +1651,7 @@ int ext3x_job_control(opal_list_t *targets, PMIX_INFO_CREATE(op->info, op->ninfo); n=0; OPAL_LIST_FOREACH(iptr, directives, opal_value_t) { - (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); ext3x_value_load(&op->info[n].value, iptr); ++n; } diff --git a/opal/mca/pmix/ext3x/ext3x_server_north.c b/opal/mca/pmix/ext3x/ext3x_server_north.c index 0628c3705a..c22e8862a4 100644 --- a/opal/mca/pmix/ext3x/ext3x_server_north.c +++ b/opal/mca/pmix/ext3x/ext3x_server_north.c @@ -35,6 +35,7 @@ #include "opal/util/output.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "ext3x.h" @@ -508,7 +509,7 @@ static void opal_lkupcbfunc(int status, /* convert the jobid */ (void)opal_snprintf_jobid(d[n].proc.nspace, PMIX_MAX_NSLEN, p->proc.jobid); d[n].proc.rank = ext3x_convert_opalrank(p->proc.vpid); - (void)strncpy(d[n].key, p->value.key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(d[n].key, p->value.key, PMIX_MAX_KEYLEN); ext3x_value_load(&d[n].value, &p->value); } } @@ -943,7 +944,7 @@ static void info_cbfunc(int status, PMIX_INFO_CREATE(pcaddy->info, pcaddy->ninfo); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pcaddy->info[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pcaddy->info[n].key, kv->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pcaddy->info[n].value, kv); ++n; } @@ -1051,7 +1052,7 @@ static void toolcbfunc(int status, p.rank = ext3x_convert_opalrank(proc.vpid); /* store this job in our list of known nspaces */ job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, p.nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, p.nspace, PMIX_MAX_NSLEN); job->jobid = proc.jobid; OPAL_PMIX_ACQUIRE_THREAD(&opal_pmix_base.lock); opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); diff --git a/opal/mca/pmix/ext3x/ext3x_server_south.c b/opal/mca/pmix/ext3x/ext3x_server_south.c index 65ef9270e0..71e3cad378 100644 --- a/opal/mca/pmix/ext3x/ext3x_server_south.c +++ b/opal/mca/pmix/ext3x/ext3x_server_south.c @@ -39,6 +39,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/proc.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/base/base.h" #include "ext3x.h" @@ -123,7 +124,7 @@ int ext3x_server_init(opal_pmix_server_module_t *module, n = 0; if (NULL != info) { OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, kv); ++n; } @@ -264,7 +265,7 @@ int ext3x_server_register_nspace(opal_jobid_t jobid, /* store this job in our list of known nspaces */ job = OBJ_NEW(opal_ext3x_jobid_trkr_t); - (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(job->nspace, nspace, PMIX_MAX_NSLEN); job->jobid = jobid; opal_list_append(&mca_pmix_ext3x_component.jobids, &job->super); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -274,7 +275,7 @@ int ext3x_server_register_nspace(opal_jobid_t jobid, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); if (0 == strcmp(kv->key, OPAL_PMIX_PROC_DATA)) { pinfo[n].value.type = PMIX_DATA_ARRAY; /* the value contains a list of values - convert @@ -289,7 +290,7 @@ int ext3x_server_register_nspace(opal_jobid_t jobid, pinfo[n].value.data.darray->size = szmap; m = 0; OPAL_LIST_FOREACH(k2, pmapinfo, opal_value_t) { - (void)strncpy(pmap[m].key, k2->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pmap[m].key, k2->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pmap[m].value, k2); ++m; } @@ -421,7 +422,7 @@ void ext3x_server_deregister_client(const opal_process_name_t *proc, OPAL_LIST_FOREACH(jptr, &mca_pmix_ext3x_component.jobids, opal_ext3x_jobid_trkr_t) { if (jptr->jobid == proc->jobid) { /* found it - tell the server to deregister */ - (void)strncpy(p.nspace, jptr->nspace, PMIX_MAX_NSLEN); + (void)opal_string_copy(p.nspace, jptr->nspace, PMIX_MAX_NSLEN); p.rank = ext3x_convert_opalrank(proc->vpid); OPAL_PMIX_CONSTRUCT_LOCK(&lock); OPAL_PMIX_RELEASE_THREAD(&opal_pmix_base.lock); @@ -529,7 +530,7 @@ int ext3x_server_notify_event(int status, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); if (0 == strcmp(kv->key, OPAL_PMIX_JOB_TERM_STATUS)) { pinfo[n].value.type = PMIX_STATUS; pinfo[n].value.data.status = ext3x_convert_opalrc(kv->data.integer); @@ -712,7 +713,7 @@ int ext3x_server_setup_application(opal_jobid_t jobid, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, kv); ++n; } @@ -764,7 +765,7 @@ int ext3x_server_setup_local_support(opal_jobid_t jobid, PMIX_INFO_CREATE(pinfo, sz); n = 0; OPAL_LIST_FOREACH(kv, info, opal_value_t) { - (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + (void)opal_string_copy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); ext3x_value_load(&pinfo[n].value, kv); ++n; } diff --git a/opal/mca/pstat/test/pstat_test.c b/opal/mca/pstat/test/pstat_test.c index 6d616afe2a..99609efdb3 100644 --- a/opal/mca/pstat/test/pstat_test.c +++ b/opal/mca/pstat/test/pstat_test.c @@ -32,6 +32,7 @@ #include "opal/mca/pstat/pstat.h" #include "opal/mca/pstat/base/base.h" +#include "opal/util/string_copy.h" #include "pstat_test.h" @@ -84,10 +85,10 @@ static int query(pid_t pid, if (NULL != stats) { gethostname(hostname, sizeof(hostname)); - strncpy(stats->node, hostname, OPAL_PSTAT_MAX_STRING_LEN); + opal_string_copy(stats->node, hostname, OPAL_PSTAT_MAX_STRING_LEN); stats->pid = pid; - strncpy(stats->cmd, "UNKNOWN", OPAL_PSTAT_MAX_STRING_LEN); + opal_string_copy(stats->cmd, "UNKNOWN", OPAL_PSTAT_MAX_STRING_LEN); stats->state[0] = 'R'; stats->priority = 2; stats->num_threads = 1; diff --git a/opal/mca/rcache/udreg/rcache_udreg_module.c b/opal/mca/rcache/udreg/rcache_udreg_module.c index d3045247f1..f6fc44e8c3 100644 --- a/opal/mca/rcache/udreg/rcache_udreg_module.c +++ b/opal/mca/rcache/udreg/rcache_udreg_module.c @@ -37,6 +37,7 @@ #include "opal/runtime/opal_params.h" #include "opal/include/opal_stdint.h" #include "opal/util/sys_limits.h" +#include "opal/util/string_copy.h" #include @@ -92,7 +93,7 @@ int mca_rcache_udreg_module_init (mca_rcache_udreg_module_t *rcache) OBJ_CONSTRUCT(&rcache->lock, opal_mutex_t); - strncpy (cache_attr.cache_name, rcache->resources.base.cache_name, UDREG_MAX_CACHENAME_LEN); + opal_string_copy (cache_attr.cache_name, rcache->resources.base.cache_name, UDREG_MAX_CACHENAME_LEN); cache_attr.max_entries = rcache->resources.max_entries; cache_attr.debug_mode = 0; cache_attr.debug_rank = 0; diff --git a/opal/mca/reachable/netlink/reachable_netlink_module.c b/opal/mca/reachable/netlink/reachable_netlink_module.c index d7550e0d6d..11ba4f4864 100644 --- a/opal/mca/reachable/netlink/reachable_netlink_module.c +++ b/opal/mca/reachable/netlink/reachable_netlink_module.c @@ -20,6 +20,7 @@ #endif #include "opal/util/net.h" +#include "opal/util/string_copy.h" #include "opal/mca/reachable/base/base.h" #include "reachable_netlink.h" #include "libnl_utils.h" @@ -92,11 +93,11 @@ static int get_weights(opal_if_t *local_if, opal_if_t *remote_if) /* opal_net_get_hostname returns a static buffer. Great for single address printfs, need to copy in this case */ - strncpy(str_local, + opal_string_copy(str_local, opal_net_get_hostname((struct sockaddr *)&local_if->if_addr), sizeof(str_local)); str_local[sizeof(str_local) - 1] = '\0'; - strncpy(str_remote, + opal_string_copy(str_remote, opal_net_get_hostname((struct sockaddr *)&remote_if->if_addr), sizeof(str_remote)); str_remote[sizeof(str_remote) - 1] = '\0'; diff --git a/opal/mca/reachable/weighted/reachable_weighted.c b/opal/mca/reachable/weighted/reachable_weighted.c index 5157c9469f..512282a403 100644 --- a/opal/mca/reachable/weighted/reachable_weighted.c +++ b/opal/mca/reachable/weighted/reachable_weighted.c @@ -31,6 +31,7 @@ #include "opal/mca/reachable/base/base.h" #include "reachable_weighted.h" #include "opal/util/net.h" +#include "opal/util/string_copy.h" static int weighted_init(void); static int weighted_fini(void); @@ -120,9 +121,9 @@ static int get_weights(opal_if_t *local_if, opal_if_t *remote_if) /* opal_net_get_hostname returns a static buffer. Great for single address printfs, need to copy in this case */ - strncpy(str_local, opal_net_get_hostname(local_sockaddr), sizeof(str_local)); + opal_string_copy(str_local, opal_net_get_hostname(local_sockaddr), sizeof(str_local)); str_local[sizeof(str_local) - 1] = '\0'; - strncpy(str_remote, opal_net_get_hostname(remote_sockaddr), sizeof(str_remote)); + opal_string_copy(str_remote, opal_net_get_hostname(remote_sockaddr), sizeof(str_remote)); str_remote[sizeof(str_remote) - 1] = '\0'; /* initially, assume no connection is possible */ diff --git a/opal/mca/shmem/mmap/shmem_mmap_module.c b/opal/mca/shmem/mmap/shmem_mmap_module.c index 23e91b5eae..dc383cab82 100644 --- a/opal/mca/shmem/mmap/shmem_mmap_module.c +++ b/opal/mca/shmem/mmap/shmem_mmap_module.c @@ -53,6 +53,7 @@ #include "opal/util/output.h" #include "opal/util/path.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/mca/shmem/shmem.h" #include "opal/mca/shmem/base/base.h" @@ -437,7 +438,7 @@ segment_create(opal_shmem_ds_t *ds_buf, ds_buf->seg_cpid = my_pid; ds_buf->seg_size = real_size; ds_buf->seg_base_addr = (unsigned char *)seg_hdrp; - (void)strncpy(ds_buf->seg_name, real_file_name, OPAL_PATH_MAX - 1); + (void)opal_string_copy(ds_buf->seg_name, real_file_name, OPAL_PATH_MAX); /* set "valid" bit because setment creation was successful */ OPAL_SHMEM_DS_SET_VALID(ds_buf); diff --git a/opal/test/reachable/reachable_shared.h b/opal/test/reachable/reachable_shared.h index 4b9941a03d..598106777a 100644 --- a/opal/test/reachable/reachable_shared.h +++ b/opal/test/reachable/reachable_shared.h @@ -16,6 +16,7 @@ #include "opal/runtime/opal.h" #include "opal/mca/reachable/reachable.h" #include "opal/util/if.h" +#include "opal/util/string_copy.h" BEGIN_C_DECLS @@ -23,7 +24,7 @@ BEGIN_C_DECLS opal_if_t* create_if(int af_family, char *address, int mask, int bandwidth) { opal_if_t *interface = OBJ_NEW(opal_if_t); - strncpy(interface->if_name, "interface0", IF_NAMESIZE); + opal_string_copy(interface->if_name, "interface0", IF_NAMESIZE); interface->af_family = af_family; ((struct sockaddr *)&(interface->if_addr))->sa_family = af_family; diff --git a/opal/util/argv.c b/opal/util/argv.c index aabb84127f..c5c4de7168 100644 --- a/opal/util/argv.c +++ b/opal/util/argv.c @@ -26,6 +26,7 @@ #include #include "opal/util/argv.h" +#include "opal/util/string_copy.h" #include "opal/constants.h" #define ARGSIZE 128 @@ -215,7 +216,7 @@ static char **opal_argv_split_inter(const char *src_string, int delimiter, if (NULL == argtemp) return NULL; - strncpy(argtemp, src_string, arglen); + opal_string_copy(argtemp, src_string, arglen + 1); argtemp[arglen] = '\0'; if (OPAL_SUCCESS != opal_argv_append(&argc, &argv, argtemp)) { @@ -229,7 +230,7 @@ static char **opal_argv_split_inter(const char *src_string, int delimiter, /* short argument, copy to buffer and add */ else { - strncpy(arg, src_string, arglen); + opal_string_copy(arg, src_string, arglen + 1); arg[arglen] = '\0'; if (OPAL_SUCCESS != opal_argv_append(&argc, &argv, arg)) diff --git a/opal/util/basename.c b/opal/util/basename.c index 1558f4554f..ab63e48e42 100644 --- a/opal/util/basename.c +++ b/opal/util/basename.c @@ -126,11 +126,7 @@ char* opal_dirname(const char* filename) if (NULL == ret) { return NULL; } -#ifdef HAVE_STRNCPY_S - strncpy_s( ret, (p - filename + 1), filename, p - filename ); -#else - strncpy(ret, filename, p - filename); -#endif + opal_string_copy(ret, filename, p - filename); ret[p - filename] = '\0'; return opal_make_filename_os_friendly(ret); } diff --git a/opal/util/error.c b/opal/util/error.c index f91a84b4e3..d8021b63ea 100644 --- a/opal/util/error.c +++ b/opal/util/error.c @@ -32,6 +32,7 @@ #include #include "opal/util/error.h" +#include "opal/util/string_copy.h" #include "opal/constants.h" #include "opal/util/proc.h" #include "opal/runtime/opal_params.h" @@ -161,7 +162,7 @@ opal_strerror_r(int errnum, char *strerrbuf, size_t buflen) if (OPAL_SUCCESS != ret) { if (errnum == OPAL_ERR_IN_ERRNO) { char *tmp = strerror(errno); - strncpy(strerrbuf, tmp, buflen); + opal_string_copy(strerrbuf, tmp, buflen); return OPAL_SUCCESS; } else { char *ue_msg; @@ -197,7 +198,7 @@ opal_error_register(const char *project, int err_base, int err_max, for (i = 0 ; i < MAX_CONVERTERS ; ++i) { if (0 == converters[i].init) { converters[i].init = 1; - strncpy(converters[i].project, project, MAX_CONVERTER_PROJECT_LEN); + opal_string_copy(converters[i].project, project, MAX_CONVERTER_PROJECT_LEN); converters[i].project[MAX_CONVERTER_PROJECT_LEN-1] = '\0'; converters[i].err_base = err_base; converters[i].err_max = err_max; diff --git a/opal/util/ethtool.c b/opal/util/ethtool.c index c44bed21bc..afe92397da 100644 --- a/opal/util/ethtool.c +++ b/opal/util/ethtool.c @@ -39,6 +39,7 @@ #include "opal/util/ethtool.h" #include "opal/util/if.h" +#include "opal/util/string_copy.h" /* * Obtain an appropriate bandwidth for the interface if_name. On Linux, we @@ -63,9 +64,7 @@ opal_ethtool_get_speed (const char *if_name) } memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_name, if_name, IF_NAMESIZE); - /* strncpy does not null terminate when the string is truncated */ - ifr.ifr_name[IF_NAMESIZE-1] = '\0'; + opal_string_copy(ifr.ifr_name, if_name, IF_NAMESIZE); ifr.ifr_data = (char *)&edata; if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) { diff --git a/opal/util/fd.c b/opal/util/fd.c index 3b320e2442..7891beb8e7 100644 --- a/opal/util/fd.c +++ b/opal/util/fd.c @@ -36,6 +36,7 @@ #include #include "opal/util/fd.h" +#include "opal/util/string_copy.h" #include "opal/constants.h" @@ -177,7 +178,7 @@ const char *opal_fd_get_peer_name(int fd) #endif else { // This string is guaranteed to be <= INET_ADDRSTRLEN - strncpy(str, "Unknown", len); + opal_string_copy(str, "Unknown", len); ret = str; } diff --git a/opal/util/if.c b/opal/util/if.c index caa549db9b..740d0e038e 100644 --- a/opal/util/if.c +++ b/opal/util/if.c @@ -81,6 +81,7 @@ #include "opal/util/output.h" #include "opal/util/argv.h" #include "opal/util/show_help.h" +#include "opal/util/string_copy.h" #include "opal/constants.h" #include "opal/mca/if/base/base.h" @@ -205,7 +206,7 @@ int opal_ifaddrtoname(const char* if_addr, char* if_name, int length) memcpy (&ipv4, r->ai_addr, r->ai_addrlen); if (inaddr->sin_addr.s_addr == ipv4.sin_addr.s_addr) { - strncpy(if_name, intf->if_name, length); + opal_string_copy(if_name, intf->if_name, length); freeaddrinfo (res); return OPAL_SUCCESS; } @@ -214,7 +215,7 @@ int opal_ifaddrtoname(const char* if_addr, char* if_name, int length) else { if (IN6_ARE_ADDR_EQUAL(&((struct sockaddr_in6*) &intf->if_addr)->sin6_addr, &((struct sockaddr_in6*) r->ai_addr)->sin6_addr)) { - strncpy(if_name, intf->if_name, length); + opal_string_copy(if_name, intf->if_name, length); freeaddrinfo (res); return OPAL_SUCCESS; } @@ -463,7 +464,7 @@ int opal_ifindextoname(int if_index, char* if_name, int length) OPAL_LIST_FOREACH(intf, &opal_if_list, opal_if_t) { if (intf->if_index == if_index) { - strncpy(if_name, intf->if_name, length); + opal_string_copy(if_name, intf->if_name, length); return OPAL_SUCCESS; } } @@ -482,7 +483,7 @@ int opal_ifkindextoname(int if_kindex, char* if_name, int length) OPAL_LIST_FOREACH(intf, &opal_if_list, opal_if_t) { if (intf->if_kernel_index == if_kindex) { - strncpy(if_name, intf->if_name, length); + opal_string_copy(if_name, intf->if_name, length); return OPAL_SUCCESS; } } diff --git a/opal/util/info.c b/opal/util/info.c index a88efe41c8..7c97bd183b 100644 --- a/opal/util/info.c +++ b/opal/util/info.c @@ -41,8 +41,7 @@ #include "opal/util/argv.h" #include "opal/util/opal_getcwd.h" #include "opal/util/output.h" -#include "opal/util/strncpy.h" - +#include "opal/util/string_copy.h" #include "opal/util/info.h" /* @@ -107,23 +106,8 @@ static void opal_info_get_nolock (opal_info_t *info, const char *key, int valuel * We have found the element, so we can return the value * Set the flag, value_length and value */ - *flag = 1; - value_length = strlen(search->ie_value); - /* - * If the stored value is shorter than valuelen, then - * we can copy the entire value out. Else, we have to - * copy ONLY valuelen bytes out - */ - if (value_length < valuelen ) { - strcpy(value, search->ie_value); - } else { - opal_strncpy(value, search->ie_value, valuelen); - if (OPAL_MAX_INFO_VAL == valuelen) { - value[valuelen-1] = 0; - } else { - value[valuelen] = 0; - } - } + *flag = 1; + opal_string_copy(value, search->ie_value, valuelen); } } @@ -152,7 +136,7 @@ static int opal_info_set_nolock (opal_info_t *info, const char *key, const char OPAL_THREAD_UNLOCK(info->i_lock); return OPAL_ERR_OUT_OF_RESOURCE; } - strncpy (new_info->ie_key, key, OPAL_MAX_INFO_KEY); + opal_string_copy (new_info->ie_key, key, OPAL_MAX_INFO_KEY); new_info->ie_value = new_value; opal_list_append (&(info->super), (opal_list_item_t *) new_info); } @@ -472,7 +456,7 @@ int opal_info_get_nthkey (opal_info_t *info, int n, char *key) * cast it to opal_info_entry_t before we can use it to * access the value */ - strncpy(key, iterator->ie_key, OPAL_MAX_INFO_KEY); + opal_string_copy(key, iterator->ie_key, OPAL_MAX_INFO_KEY); OPAL_THREAD_UNLOCK(info->i_lock); return OPAL_SUCCESS; } diff --git a/opal/util/info_subscriber.c b/opal/util/info_subscriber.c index 5b0544e36d..7c5491434c 100644 --- a/opal/util/info_subscriber.c +++ b/opal/util/info_subscriber.c @@ -41,7 +41,6 @@ #include "opal/util/argv.h" #include "opal/util/opal_getcwd.h" #include "opal/util/output.h" -#include "opal/util/strncpy.h" #include "opal/util/info_subscriber.h" static char* opal_infosubscribe_inform_subscribers(opal_infosubscriber_t * object, char *key, char *new_value, int *found_callback); diff --git a/opal/util/keyval_parse.c b/opal/util/keyval_parse.c index aef56d8c37..c08cfa2194 100644 --- a/opal/util/keyval_parse.c +++ b/opal/util/keyval_parse.c @@ -25,6 +25,7 @@ #include "opal/util/keyval_parse.h" #include "opal/util/keyval/keyval_lex.h" #include "opal/util/output.h" +#include "opal/util/string_copy.h" #include "opal/threads/mutex.h" #include #include @@ -144,7 +145,7 @@ static int parse_line(void) key_buffer = tmp; } - strncpy(key_buffer, opal_util_keyval_yytext, key_buffer_len); + opal_string_copy(key_buffer, opal_util_keyval_yytext, key_buffer_len); /* The first thing we have to see is an "=" */ @@ -267,7 +268,7 @@ static int save_param_name (void) key_buffer = tmp; } - strncpy (key_buffer, opal_util_keyval_yytext, key_buffer_len); + opal_string_copy (key_buffer, opal_util_keyval_yytext, key_buffer_len); return OPAL_SUCCESS; } diff --git a/opal/util/opal_getcwd.c b/opal/util/opal_getcwd.c index e529c008e7..4ac08300e1 100644 --- a/opal/util/opal_getcwd.c +++ b/opal/util/opal_getcwd.c @@ -24,6 +24,7 @@ #include "opal/util/basename.h" #include "opal/util/opal_getcwd.h" +#include "opal/util/string_copy.h" #include "opal/constants.h" @@ -90,13 +91,11 @@ int opal_getcwd(char *buf, size_t size) * of the basename as possible */ shortened = opal_basename(pwd); - strncpy(buf, shortened, size); + opal_string_copy(buf, shortened, size); free(shortened); - /* ensure it is null terminated */ - buf[size-1] = '\0'; /* indicate that it isn't the full path */ return OPAL_ERR_TEMP_OUT_OF_RESOURCE; } - strncpy(buf, pwd, size); + opal_string_copy(buf, pwd, size); return OPAL_SUCCESS; } diff --git a/opal/util/output.c b/opal/util/output.c index 36a6b517b9..eabd8cd393 100644 --- a/opal/util/output.c +++ b/opal/util/output.c @@ -43,6 +43,7 @@ #include "opal/util/opal_environ.h" #include "opal/util/output.h" +#include "opal/util/string_copy.h" #include "opal/threads/mutex.h" #include "opal/constants.h" #include "opal/mca/pmix/pmix.h" @@ -769,7 +770,7 @@ static int open_file(int i) if (NULL == filename) { return OPAL_ERR_OUT_OF_RESOURCE; } - strncpy(filename, output_dir, OPAL_PATH_MAX); + opal_string_copy(filename, output_dir, OPAL_PATH_MAX); strcat(filename, "/"); if (NULL != output_prefix) { strcat(filename, output_prefix); diff --git a/opal/util/proc.c b/opal/util/proc.c index 7dcdcff911..9c66b6b835 100644 --- a/opal/util/proc.c +++ b/opal/util/proc.c @@ -16,9 +16,12 @@ * $HEADER$ */ +#include "opal_config.h" + #include "proc.h" #include "opal/util/proc.h" #include "opal/util/arch.h" +#include "opal/util/string_copy.h" #include "opal/mca/pmix/pmix.h" opal_process_name_t opal_name_wildcard = {OPAL_JOBID_WILDCARD, OPAL_VPID_WILDCARD}; @@ -157,7 +160,7 @@ static int opal_convert_process_name_to_string_should_never_be_called(char** nam static int opal_snprintf_jobid_should_never_be_called(char* name_string, size_t size, opal_jobid_t jobid) { - (void)strncpy(name_string, "My JOBID", size); + (void)opal_string_copy(name_string, "My JOBID", size); return OPAL_SUCCESS; } diff --git a/opal/win32/opal_utsname.c b/opal/win32/opal_utsname.c index 693e0ad5e6..b6d06876fb 100644 --- a/opal/win32/opal_utsname.c +++ b/opal/win32/opal_utsname.c @@ -18,6 +18,7 @@ #include "opal_config.h" #include "opal/win32/opal_utsname.h" +#include "opal/util/string_copy.h" /* This has to fill in the following information @@ -42,7 +43,7 @@ int uname( struct utsname *un ) snprintf( un->sysname, OPAL_UTSNAME_LEN, "Unknown" ); } else { /* remove the "OS=" from the beginning of the string */ - strncpy( un->sysname, info_buf + 3, OPAL_UTSNAME_LEN ); + opal_string_copy( un->sysname, info_buf + 3, OPAL_UTSNAME_LEN ); } info_buf_count = OPAL_UTSNAME_LEN; if (!GetComputerName( un->nodename, &info_buf_count)) { diff --git a/opal/win32/win_compat.h b/opal/win32/win_compat.h index c31d3bb74d..99072b9f9c 100644 --- a/opal/win32/win_compat.h +++ b/opal/win32/win_compat.h @@ -246,7 +246,6 @@ typedef unsigned int uint; #define HAVE_DECL___FUNC__ 1 #endif -/*#define strncpy strncpy_s*/ /*#define sprintf sprintf_s*/ /* Ugly signal mapping since windows doesn't support the full spectrum