summaryrefslogtreecommitdiffstats
path: root/src/vlibmemory/memory_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlibmemory/memory_client.c')
-rw-r--r--src/vlibmemory/memory_client.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c
index f032ae77d19..3e1bdff777c 100644
--- a/src/vlibmemory/memory_client.c
+++ b/src/vlibmemory/memory_client.c
@@ -195,7 +195,7 @@ vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
mp->_vl_msg_id = ntohs (VL_API_MEMCLNT_CREATE);
mp->ctx_quota = ctx_quota;
mp->input_queue = (uword) vl_input_queue;
- strncpy ((char *) mp->name, name, sizeof (mp->name) - 1);
+ vl_api_to_api_string (strnlen_s (name, 64), name, &mp->name);
vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & mp);
@@ -517,7 +517,8 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
clib_time_t clib_time;
u16 rv = ~0;
- if (strlen (plugin_name) + 1 > sizeof (mp->name))
+ size_t plugin_name_len = strnlen_s (plugin_name, 128);
+ if (plugin_name_len == 128)
return (rv);
clib_memset (&clib_time, 0, sizeof (clib_time));
@@ -538,7 +539,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID);
mp->client_index = am->my_client_index;
- strncpy ((char *) mp->name, plugin_name, sizeof (mp->name) - 1);
+ vl_api_to_api_string (plugin_name_len, plugin_name, &mp->name);
if (vl_socket_client_write () <= 0)
goto sock_err;
@@ -563,7 +564,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_GET_FIRST_MSG_ID);
mp->client_index = am->my_client_index;
- strncpy ((char *) mp->name, plugin_name, sizeof (mp->name) - 1);
+ vl_api_to_api_string (plugin_name_len, plugin_name, &mp->name);
vl_msg_api_send_shmem (am->shmem_hdr->vl_input_queue, (u8 *) & mp);