summaryrefslogtreecommitdiffstats
path: root/src/vlibmemory
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-10-17 10:38:51 -0400
committerDamjan Marion <dmarion@me.com>2018-10-23 13:06:46 +0000
commitb7b929931a07fbb27b43d5cd105f366c3e29807e (patch)
tree438681c89738802dbb5d339715b96ea2c31bafb4 /src/vlibmemory
parentb9a4c445c1d4e9cdab476a8e1fb8a46ff0fc6080 (diff)
c11 safe string handling support
Change-Id: Ied34720ca5a6e6e717eea4e86003e854031b6eab Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlibmemory')
-rw-r--r--src/vlibmemory/memory_api.c16
-rw-r--r--src/vlibmemory/memory_client.c14
-rw-r--r--src/vlibmemory/memory_shared.c4
-rw-r--r--src/vlibmemory/socket_api.c10
-rw-r--r--src/vlibmemory/socket_client.c6
-rw-r--r--src/vlibmemory/vlib_api.c8
-rw-r--r--src/vlibmemory/vlib_api_cli.c2
7 files changed, 30 insertions, 30 deletions
diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c
index 1f5da4c786e..a444ec785a7 100644
--- a/src/vlibmemory/memory_api.c
+++ b/src/vlibmemory/memory_api.c
@@ -127,7 +127,7 @@ vl_api_memclnt_create_internal (char *name, svm_queue_t * q)
*regpp = clib_mem_alloc (sizeof (vl_api_registration_t));
regp = *regpp;
- memset (regp, 0, sizeof (*regp));
+ clib_memset (regp, 0, sizeof (*regp));
regp->registration_type = REGISTRATION_TYPE_SHMEM;
regp->vl_api_registration_pool_index = regpp - am->vl_clients;
regp->vlib_rp = svm;
@@ -194,7 +194,7 @@ vl_api_memclnt_create_t_handler (vl_api_memclnt_create_t * mp)
*regpp = clib_mem_alloc (sizeof (vl_api_registration_t));
regp = *regpp;
- memset (regp, 0, sizeof (*regp));
+ clib_memset (regp, 0, sizeof (*regp));
regp->registration_type = REGISTRATION_TYPE_SHMEM;
regp->vl_api_registration_pool_index = regpp - am->vl_clients;
regp->vlib_rp = svm;
@@ -346,7 +346,7 @@ vl_api_memclnt_delete_t_handler (vl_api_memclnt_delete_t * mp)
oldheap = svm_push_data_heap (svm);
vec_free (regp->name);
/* Poison the old registration */
- memset (regp, 0xF1, sizeof (*regp));
+ clib_memset (regp, 0xF1, sizeof (*regp));
clib_mem_free (regp);
pthread_mutex_unlock (&svm->mutex);
svm_pop_heap (oldheap);
@@ -400,7 +400,7 @@ vl_api_memclnt_keepalive_t_handler (vl_api_memclnt_keepalive_t * mp)
shmem_hdr = am->shmem_hdr;
rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
+ clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_MEMCLNT_KEEPALIVE_REPLY);
rmp->context = mp->context;
vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & rmp);
@@ -425,7 +425,7 @@ vl_mem_api_init (const char *region_name)
vl_shmem_hdr_t *shm;
vlib_main_t *vm = vlib_get_main ();
- memset (c, 0, sizeof (*c));
+ clib_memset (c, 0, sizeof (*c));
if ((rv = vl_map_shmem (region_name, 1 /* is_vlib */ )) < 0)
return rv;
@@ -513,7 +513,7 @@ send_memclnt_keepalive (vl_api_registration_t * regp, f64 now)
am->shmem_hdr = regp->shmem_hdr;
mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MEMCLNT_KEEPALIVE);
mp->context = mp->client_index =
vl_msg_api_handle_from_index_and_epoch
@@ -658,7 +658,7 @@ vl_mem_api_dead_client_scan (api_main_t * am, vl_shmem_hdr_t * shm, f64 now)
else
{
/* Poison the old registration */
- memset (*regpp, 0xF3, sizeof (**regpp));
+ clib_memset (*regpp, 0xF3, sizeof (**regpp));
clib_mem_free (*regpp);
}
/* no dangling references, please */
@@ -899,7 +899,7 @@ vlibmemory_init (vlib_main_t * vm)
svm_map_region_args_t _a, *a = &_a;
clib_error_t *error;
- memset (a, 0, sizeof (*a));
+ clib_memset (a, 0, sizeof (*a));
a->root_path = am->root_path;
a->name = SVM_GLOBAL_REGION_NAME;
a->baseva = (am->global_baseva != 0) ?
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c
index 07eb83eaa7c..239cbfee36f 100644
--- a/src/vlibmemory/memory_client.c
+++ b/src/vlibmemory/memory_client.c
@@ -209,7 +209,7 @@ vl_client_connect (const char *name, int ctx_quota, int input_queue_size)
am->vl_input_queue = vl_input_queue;
mp = vl_msg_api_alloc (sizeof (vl_api_memclnt_create_t));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_MEMCLNT_CREATE);
mp->ctx_quota = ctx_quota;
mp->input_queue = (uword) vl_input_queue;
@@ -287,7 +287,7 @@ vl_client_disconnect (void)
vl_input_queue = am->vl_input_queue;
mp = vl_msg_api_alloc (sizeof (vl_api_memclnt_delete_t));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_MEMCLNT_DELETE);
mp->index = am->my_client_index;
mp->handle = (uword) am->my_registration;
@@ -346,7 +346,7 @@ vl_api_memclnt_keepalive_t_handler (vl_api_memclnt_keepalive_t * mp)
shmem_hdr = am->shmem_hdr;
rmp = vl_msg_api_alloc_as_if_client (sizeof (*rmp));
- memset (rmp, 0, sizeof (*rmp));
+ clib_memset (rmp, 0, sizeof (*rmp));
rmp->_vl_msg_id = ntohs (VL_API_MEMCLNT_KEEPALIVE_REPLY);
rmp->context = mp->context;
vl_msg_api_send_shmem (shmem_hdr->vl_input_queue, (u8 *) & rmp);
@@ -481,7 +481,7 @@ disconnect_from_vlib_internal (u8 do_unmap)
if (do_unmap)
vl_client_api_unmap ();
}
- memset (mm, 0, sizeof (*mm));
+ clib_memset (mm, 0, sizeof (*mm));
}
void
@@ -520,7 +520,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
if (strlen (plugin_name) + 1 > sizeof (mp->name))
return (rv);
- memset (&clib_time, 0, sizeof (clib_time));
+ clib_memset (&clib_time, 0, sizeof (clib_time));
clib_time_init (&clib_time);
/* Push this plugin's first_msg_id_reply handler */
@@ -535,7 +535,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
if (!am->my_registration)
{
mp = vl_socket_client_msg_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
+ 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);
@@ -560,7 +560,7 @@ vl_client_get_first_plugin_msg_id (const char *plugin_name)
else
{
mp = vl_msg_api_alloc (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
+ 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);
diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c
index 084d0b77b62..0604b0a1cdf 100644
--- a/src/vlibmemory/memory_shared.c
+++ b/src/vlibmemory/memory_shared.c
@@ -518,7 +518,7 @@ vl_map_shmem (const char *region_name, int is_vlib)
struct timespec ts, tsrem;
char *vpe_api_region_suffix = "-vpe-api";
- memset (a, 0, sizeof (*a));
+ clib_memset (a, 0, sizeof (*a));
if (strstr (region_name, vpe_api_region_suffix))
{
@@ -590,7 +590,7 @@ vl_map_shmem (const char *region_name, int is_vlib)
ts = tsrem;
}
/* Mutex buggered, "fix" it */
- memset (&q->mutex, 0, sizeof (q->mutex));
+ clib_memset (&q->mutex, 0, sizeof (q->mutex));
clib_warning ("forcibly release main input queue mutex");
mutex_ok:
diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c
index f3cd169d2c0..3cf2a1cfe74 100644
--- a/src/vlibmemory/socket_api.c
+++ b/src/vlibmemory/socket_api.c
@@ -381,7 +381,7 @@ socksvr_file_add (clib_file_main_t * fm, int fd)
clib_file_t template = { 0 };
pool_get (socket_main.registration_pool, rp);
- memset (rp, 0, sizeof (*rp));
+ clib_memset (rp, 0, sizeof (*rp));
template.read_function = vl_socket_read_ready;
template.write_function = vl_socket_write_ready;
@@ -506,7 +506,7 @@ vl_sock_api_send_fd_msg (int socket_fd, int fds[], int n_fds)
mh.msg_iov = iov;
mh.msg_iovlen = 1;
- memset (&ctl, 0, sizeof (ctl));
+ clib_memset (&ctl, 0, sizeof (ctl));
mh.msg_control = ctl;
mh.msg_controllen = sizeof (ctl);
cmsg = CMSG_FIRSTHDR (&mh);
@@ -609,7 +609,7 @@ vl_api_sock_init_shm_t_handler (vl_api_sock_init_shm_t * mp)
* Set up a memfd segment of the requested size wherein the
* shmem data structures will be initialized
*/
- memset (memfd, 0, sizeof (*memfd));
+ clib_memset (memfd, 0, sizeof (*memfd));
memfd->ssvm_size = mp->requested_size;
memfd->requested_va = 0ULL;
memfd->i_am_master = 1;
@@ -624,7 +624,7 @@ vl_api_sock_init_shm_t_handler (vl_api_sock_init_shm_t * mp)
/*
* Create a plausible svm_region in the memfd backed segment
*/
- memset (a, 0, sizeof (*a));
+ clib_memset (a, 0, sizeof (*a));
a->baseva = memfd->sh->ssvm_va + MMAP_PAGESIZE;
a->size = memfd->ssvm_size - MMAP_PAGESIZE;
/* $$$$ might want a different config parameter */
@@ -729,7 +729,7 @@ vl_sock_api_init (vlib_main_t * vm)
return error;
pool_get (sm->registration_pool, rp);
- memset (rp, 0, sizeof (*rp));
+ clib_memset (rp, 0, sizeof (*rp));
rp->registration_type = REGISTRATION_TYPE_SOCKET_LISTEN;
diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c
index c04b804eb21..febb737ac2d 100644
--- a/src/vlibmemory/socket_client.c
+++ b/src/vlibmemory/socket_client.c
@@ -214,7 +214,7 @@ vl_sock_api_recv_fd_msg (int socket_fd, int fds[], int n_fds, u32 wait)
mh.msg_control = ctl;
mh.msg_controllen = sizeof (ctl);
- memset (ctl, 0, sizeof (ctl));
+ clib_memset (ctl, 0, sizeof (ctl));
if (wait != ~0)
{
@@ -282,7 +282,7 @@ static void vl_api_sock_init_shm_reply_t_handler
return;
}
- memset (memfd, 0, sizeof (*memfd));
+ clib_memset (memfd, 0, sizeof (*memfd));
memfd->fd = my_fd;
/* Note: this closes memfd.fd */
@@ -404,7 +404,7 @@ vl_socket_client_init_shm (vl_api_shm_elem_config_t * config)
mp = vl_socket_client_msg_alloc (sizeof (*mp) +
vec_len (config) * sizeof (u64));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_SOCK_INIT_SHM);
mp->client_index = clib_host_to_net_u32 (scm->client_index);
mp->requested_size = 64 << 20;
diff --git a/src/vlibmemory/vlib_api.c b/src/vlibmemory/vlib_api.c
index 15a0ba82f12..b72f1335c29 100644
--- a/src/vlibmemory/vlib_api.c
+++ b/src/vlibmemory/vlib_api.c
@@ -143,7 +143,7 @@ vl_api_api_versions_t_handler (vl_api_api_versions_t * mp)
return;
rmp = vl_msg_api_alloc (msg_size);
- memset (rmp, 0, msg_size);
+ clib_memset (rmp, 0, msg_size);
rmp->_vl_msg_id = ntohs (VL_API_API_VERSIONS_REPLY);
/* fill in the message */
@@ -178,7 +178,7 @@ vlib_api_init (void)
vl_msg_api_msg_config_t cfg;
vl_msg_api_msg_config_t *c = &cfg;
- memset (c, 0, sizeof (*c));
+ clib_memset (c, 0, sizeof (*c));
#define _(N,n) do { \
c->id = VL_API_##N; \
@@ -213,7 +213,7 @@ send_one_plugin_msg_ids_msg (u8 * name, u16 first_msg_id, u16 last_msg_id)
svm_queue_t *q;
mp = vl_msg_api_alloc_as_if_client (sizeof (*mp));
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_TRACE_PLUGIN_MSG_IDS);
strncpy ((char *) mp->plugin_name, (char *) name,
@@ -620,7 +620,7 @@ vl_api_rpc_call_main_thread_inline (void *fp, u8 * data, u32 data_length,
/* Otherwise, actually do an RPC */
mp = vl_msg_api_alloc_as_if_client (sizeof (*mp) + data_length);
- memset (mp, 0, sizeof (*mp));
+ clib_memset (mp, 0, sizeof (*mp));
clib_memcpy (mp->data, data, data_length);
mp->_vl_msg_id = ntohs (VL_API_RPC_CALL);
mp->function = pointer_to_uword (fp);
diff --git a/src/vlibmemory/vlib_api_cli.c b/src/vlibmemory/vlib_api_cli.c
index d6eca598d75..69c4f92df4a 100644
--- a/src/vlibmemory/vlib_api_cli.c
+++ b/src/vlibmemory/vlib_api_cli.c
@@ -535,7 +535,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
/* Copy the buffer (from the read-only mmap'ed file) */
vec_validate (tmpbuf, size - 1 + sizeof (uword));
clib_memcpy (tmpbuf + sizeof (uword), msg, size);
- memset (tmpbuf, 0xf, sizeof (uword));
+ clib_memset (tmpbuf, 0xf, sizeof (uword));
/*
* Endian swap if needed. All msg data is supposed to be