|
28 | 28 | #include "opal/mca/event/event.h" |
29 | 29 | #include "opal/util/output.h" |
30 | 30 | #include "opal/util/fd.h" |
| 31 | +#include "opal/util/string_copy.h" |
31 | 32 |
|
32 | 33 | #include "btl_usnic.h" |
33 | 34 | #include "btl_usnic_module.h" |
@@ -103,7 +104,7 @@ int opal_btl_usnic_connectivity_client_init(void) |
103 | 104 | struct sockaddr_un address; |
104 | 105 | memset(&address, 0, sizeof(struct sockaddr_un)); |
105 | 106 | address.sun_family = AF_UNIX; |
106 | | - strncpy(address.sun_path, ipc_filename, sizeof(address.sun_path) - 1); |
| 107 | + opal_string_copy(address.sun_path, ipc_filename, sizeof(address.sun_path)); |
107 | 108 |
|
108 | 109 | int count = 0; |
109 | 110 | while (1) { |
@@ -195,10 +196,10 @@ int opal_btl_usnic_connectivity_listen(opal_btl_usnic_module_t *module) |
195 | 196 | } |
196 | 197 |
|
197 | 198 | /* Ensure to NULL-terminate the passed strings */ |
198 | | - strncpy(cmd.nodename, opal_process_info.nodename, |
199 | | - CONNECTIVITY_NODENAME_LEN - 1); |
200 | | - strncpy(cmd.usnic_name, module->linux_device_name, |
201 | | - CONNECTIVITY_IFNAME_LEN - 1); |
| 199 | + opal_string_copy(cmd.nodename, opal_process_info.nodename, |
| 200 | + CONNECTIVITY_NODENAME_LEN); |
| 201 | + opal_string_copy(cmd.usnic_name, module->linux_device_name, |
| 202 | + CONNECTIVITY_IFNAME_LEN); |
202 | 203 |
|
203 | 204 | if (OPAL_SUCCESS != opal_fd_write(agent_fd, sizeof(cmd), &cmd)) { |
204 | 205 | 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, |
255 | 256 | .max_msg_size = max_msg_size |
256 | 257 | }; |
257 | 258 | /* Ensure to NULL-terminate the passed string */ |
258 | | - strncpy(cmd.dest_nodename, dest_nodename, CONNECTIVITY_NODENAME_LEN - 1); |
| 259 | + opal_string_copy(cmd.dest_nodename, dest_nodename, CONNECTIVITY_NODENAME_LEN); |
259 | 260 |
|
260 | 261 | if (OPAL_SUCCESS != opal_fd_write(agent_fd, sizeof(cmd), &cmd)) { |
261 | 262 | OPAL_ERROR_LOG(OPAL_ERR_IN_ERRNO); |
|
0 commit comments