summaryrefslogtreecommitdiffstats
path: root/src/vlib
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/vlib
parentb9a4c445c1d4e9cdab476a8e1fb8a46ff0fc6080 (diff)
c11 safe string handling support
Change-Id: Ied34720ca5a6e6e717eea4e86003e854031b6eab Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/buffer.c8
-rw-r--r--src/vlib/buffer_serialize.c2
-rw-r--r--src/vlib/error.c6
-rw-r--r--src/vlib/linux/pci.c16
-rwxr-xr-xsrc/vlib/linux/physmem.c2
-rw-r--r--src/vlib/main.c2
-rw-r--r--src/vlib/node.c6
-rw-r--r--src/vlib/node.h2
-rw-r--r--src/vlib/node_funcs.h2
-rw-r--r--src/vlib/threads.c20
-rw-r--r--src/vlib/threads_cli.c4
-rw-r--r--src/vlib/unix/cj.c2
-rw-r--r--src/vlib/unix/cli.c4
-rwxr-xr-xsrc/vlib/unix/main.c2
-rw-r--r--src/vlib/unix/mc_socket.c18
15 files changed, 48 insertions, 48 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 785fa9b8aac..ee76290e25a 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -377,7 +377,7 @@ vlib_buffer_create_free_list_helper (vlib_main_t * vm,
pool_get_aligned (vm->buffer_free_list_pool, f, CLIB_CACHE_LINE_BYTES);
- memset (f, 0, sizeof (f[0]));
+ clib_memset (f, 0, sizeof (f[0]));
f->index = f - vm->buffer_free_list_pool;
f->n_data_bytes = vlib_buffer_round_size (n_data_bytes);
f->min_n_buffers_each_alloc = VLIB_FRAME_SIZE;
@@ -439,7 +439,7 @@ del_free_list (vlib_main_t * vm, vlib_buffer_free_list_t * f)
vec_free (f->buffers);
/* Poison it. */
- memset (f, 0xab, sizeof (f[0]));
+ clib_memset (f, 0xab, sizeof (f[0]));
}
/* Add buffer free list. */
@@ -544,7 +544,7 @@ vlib_buffer_fill_free_list_internal (vlib_main_t * vm,
if (CLIB_DEBUG > 0)
vlib_buffer_set_known_state (bi[0], VLIB_BUFFER_KNOWN_FREE);
- memset (b, 0, sizeof (vlib_buffer_t));
+ clib_memset (b, 0, sizeof (vlib_buffer_t));
vlib_buffer_init_for_free_list (b, fl);
if (fl->buffer_init_function)
@@ -709,7 +709,7 @@ vlib_packet_template_init (vlib_main_t * vm,
vlib_worker_thread_barrier_sync (vm);
- memset (t, 0, sizeof (t[0]));
+ clib_memset (t, 0, sizeof (t[0]));
vec_add (t->packet_data, packet_data, n_packet_data_bytes);
t->min_n_buffers_each_alloc = min_n_buffers_each_alloc;
diff --git a/src/vlib/buffer_serialize.c b/src/vlib/buffer_serialize.c
index 48dcce3be90..5696882ae0d 100644
--- a/src/vlib/buffer_serialize.c
+++ b/src/vlib/buffer_serialize.c
@@ -170,7 +170,7 @@ serialize_open_vlib_helper (serialize_main_t * m,
/* Initialize serialize main but save overflow buffer for re-use between calls. */
{
u8 *save = m->stream.overflow_buffer;
- memset (m, 0, sizeof (m[0]));
+ clib_memset (m, 0, sizeof (m[0]));
m->stream.overflow_buffer = save;
if (save)
_vec_len (save) = 0;
diff --git a/src/vlib/error.c b/src/vlib/error.c
index 9fc1e708b63..e6e4f2d5651 100644
--- a/src/vlib/error.c
+++ b/src/vlib/error.c
@@ -199,8 +199,8 @@ vlib_register_errors (vlib_main_t * vm,
em->counters_last_clear + n->error_heap_index,
n_errors * sizeof (em->counters[0]));
else
- memset (em->counters + n->error_heap_index,
- 0, n_errors * sizeof (em->counters[0]));
+ clib_memset (em->counters + n->error_heap_index,
+ 0, n_errors * sizeof (em->counters[0]));
/* Register counter indices in the stat segment directory */
{
@@ -223,7 +223,7 @@ vlib_register_errors (vlib_main_t * vm,
elog_event_type_t t;
uword i;
- memset (&t, 0, sizeof (t));
+ clib_memset (&t, 0, sizeof (t));
for (i = 0; i < n_errors; i++)
{
t.format = (char *) format (0, "%v %s: %%d",
diff --git a/src/vlib/linux/pci.c b/src/vlib/linux/pci.c
index 69fca9e6098..b55fb5042f7 100644
--- a/src/vlib/linux/pci.c
+++ b/src/vlib/linux/pci.c
@@ -180,7 +180,7 @@ vlib_pci_get_device_info (vlib_main_t * vm, vlib_pci_addr_t * addr,
int fd;
di = clib_mem_alloc (sizeof (vlib_pci_device_info_t));
- memset (di, 0, sizeof (vlib_pci_device_info_t));
+ clib_memset (di, 0, sizeof (vlib_pci_device_info_t));
di->addr.as_u32 = addr->as_u32;
u8 *dev_dir_name = format (0, "%s/%U", sysfs_pci_dev_path,
@@ -212,7 +212,7 @@ vlib_pci_get_device_info (vlib_main_t * vm, vlib_pci_addr_t * addr,
{
static pci_config_header_t all_ones;
if (all_ones.vendor_id == 0)
- memset (&all_ones, ~0, sizeof (all_ones));
+ clib_memset (&all_ones, ~0, sizeof (all_ones));
if (!memcmp (&di->config0.header, &all_ones, sizeof (all_ones)))
{
@@ -451,8 +451,8 @@ vlib_pci_bind_to_uio (vlib_main_t * vm, vlib_pci_addr_t * addr,
if (e->d_name[0] == '.') /* skip . and .. */
continue;
- memset (&ifr, 0, sizeof ifr);
- memset (&drvinfo, 0, sizeof drvinfo);
+ clib_memset (&ifr, 0, sizeof ifr);
+ clib_memset (&drvinfo, 0, sizeof drvinfo);
ifr.ifr_data = (char *) &drvinfo;
strncpy (ifr.ifr_name, e->d_name, sizeof (ifr.ifr_name));
ifr.ifr_name[ARRAY_LEN (ifr.ifr_name) - 1] = '\0';
@@ -469,7 +469,7 @@ vlib_pci_bind_to_uio (vlib_main_t * vm, vlib_pci_addr_t * addr,
if (strcmp ((char *) s, drvinfo.bus_info))
continue;
- memset (&ifr, 0, sizeof (ifr));
+ clib_memset (&ifr, 0, sizeof (ifr));
strncpy (ifr.ifr_name, e->d_name, sizeof (ifr.ifr_name));
ifr.ifr_name[ARRAY_LEN (ifr.ifr_name) - 1] = '\0';
if (ioctl (fd, SIOCGIFFLAGS, &ifr) < 0)
@@ -1138,7 +1138,7 @@ error:
if (err)
{
pci_log_err (vm, p, "%U", format_clib_error, err);
- memset (p, 0, sizeof (linux_pci_device_t));
+ clib_memset (p, 0, sizeof (linux_pci_device_t));
pool_put (lpm->linux_pci_devices, p);
}
@@ -1205,7 +1205,7 @@ vlib_pci_device_close (vlib_main_t * vm, vlib_pci_dev_handle_t h)
vec_free (p->regions);
close (p->fd);
- memset (p, 0, sizeof (linux_pci_device_t));
+ clib_memset (p, 0, sizeof (linux_pci_device_t));
pool_put (lpm->linux_pci_devices, p);
}
@@ -1244,7 +1244,7 @@ init_device_from_registered (vlib_main_t * vm, vlib_pci_device_info_t * di)
}
/* No driver, close the PCI config-space FD */
- memset (p, 0, sizeof (linux_pci_device_t));
+ clib_memset (p, 0, sizeof (linux_pci_device_t));
pool_put (lpm->linux_pci_devices, p);
}
diff --git a/src/vlib/linux/physmem.c b/src/vlib/linux/physmem.c
index dbc4c549a99..90b0f8cab3d 100755
--- a/src/vlib/linux/physmem.c
+++ b/src/vlib/linux/physmem.c
@@ -219,7 +219,7 @@ unix_physmem_region_alloc (vlib_main_t * vm, char *name, u32 size,
goto done;
error:
- memset (pr, 0, sizeof (*pr));
+ clib_memset (pr, 0, sizeof (*pr));
pool_put (vpm->regions, pr);
done:
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 273ae5256a5..14d89141ff8 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -143,7 +143,7 @@ vlib_frame_alloc_to_node (vlib_main_t * vm, u32 to_node_index,
/* Poison frame when debugging. */
if (CLIB_DEBUG > 0)
- memset (f, 0xfe, n);
+ clib_memset (f, 0xfe, n);
/* Insert magic number. */
{
diff --git a/src/vlib/node.c b/src/vlib/node.c
index ed474eb5311..c87400d440c 100644
--- a/src/vlib/node.c
+++ b/src/vlib/node.c
@@ -290,7 +290,7 @@ node_elog_init (vlib_main_t * vm, uword ni)
{
elog_event_type_t t;
- memset (&t, 0, sizeof (t));
+ clib_memset (&t, 0, sizeof (t));
/* 2 event types for this node: one when node function is called.
One when it returns. */
@@ -347,7 +347,7 @@ register_node (vlib_main_t * vm, vlib_node_registration_t * r)
ASSERT (r->function != 0);
n = clib_mem_alloc_no_fail (sizeof (n[0]));
- memset (n, 0, sizeof (n[0]));
+ clib_memset (n, 0, sizeof (n[0]));
n->index = vec_len (nm->nodes);
n->node_fn_registrations = r->node_fn_registrations;
@@ -451,7 +451,7 @@ register_node (vlib_main_t * vm, vlib_node_registration_t * r)
clib_panic ("failed to allocate process stack (%d bytes)",
1 << log2_n_stack_bytes);
- memset (p, 0, sizeof (p[0]));
+ clib_memset (p, 0, sizeof (p[0]));
p->log2_n_stack_bytes = log2_n_stack_bytes;
/* Process node's runtime index is really index into process
diff --git a/src/vlib/node.h b/src/vlib/node.h
index fd245d59def..fb2a83bc400 100644
--- a/src/vlib/node.h
+++ b/src/vlib/node.h
@@ -444,7 +444,7 @@ typedef struct
always_inline void
vlib_next_frame_init (vlib_next_frame_t * nf)
{
- memset (nf, 0, sizeof (nf[0]));
+ clib_memset (nf, 0, sizeof (nf[0]));
nf->frame_index = ~0;
nf->node_runtime_index = ~0;
}
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index a308b87e8ca..3304d0f0d9f 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -1015,7 +1015,7 @@ vlib_signal_one_time_waiting_process (vlib_main_t * vm,
{
vlib_process_signal_one_time_event (vm, p->node_index, p->one_time_event,
/* data */ ~0);
- memset (p, ~0, sizeof (p[0]));
+ clib_memset (p, ~0, sizeof (p[0]));
}
always_inline void
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 7f407e92478..c99458ddaec 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -393,7 +393,7 @@ vlib_frame_queue_alloc (int nelts)
vlib_frame_queue_t *fq;
fq = clib_mem_alloc_aligned (sizeof (*fq), CLIB_CACHE_LINE_BYTES);
- memset (fq, 0, sizeof (*fq));
+ clib_memset (fq, 0, sizeof (*fq));
fq->nelts = nelts;
fq->vector_threshold = 128; // packets
vec_validate_aligned (fq->elts, nelts - 1, CLIB_CACHE_LINE_BYTES);
@@ -775,8 +775,8 @@ start_workers (vlib_main_t * vm)
vm_clone->pending_rpc_requests = 0;
vec_validate (vm_clone->pending_rpc_requests, 0);
_vec_len (vm_clone->pending_rpc_requests) = 0;
- memset (&vm_clone->random_buffer, 0,
- sizeof (vm_clone->random_buffer));
+ clib_memset (&vm_clone->random_buffer, 0,
+ sizeof (vm_clone->random_buffer));
nm = &vlib_mains[0]->node_main;
nm_clone = &vm_clone->node_main;
@@ -812,9 +812,9 @@ start_workers (vlib_main_t * vm)
clib_memcpy (n, nm->nodes[j], sizeof (*n));
/* none of the copied nodes have enqueue rights given out */
n->owner_node_index = VLIB_INVALID_NODE_INDEX;
- memset (&n->stats_total, 0, sizeof (n->stats_total));
- memset (&n->stats_last_clear, 0,
- sizeof (n->stats_last_clear));
+ clib_memset (&n->stats_total, 0, sizeof (n->stats_total));
+ clib_memset (&n->stats_last_clear, 0,
+ sizeof (n->stats_last_clear));
vec_add1 (nm_clone->nodes, n);
n++;
}
@@ -1087,10 +1087,10 @@ vlib_worker_thread_node_refork (void)
if (j >= vec_len (old_nodes_clone))
{
/* new node, set to zero */
- memset (&new_n_clone->stats_total, 0,
- sizeof (new_n_clone->stats_total));
- memset (&new_n_clone->stats_last_clear, 0,
- sizeof (new_n_clone->stats_last_clear));
+ clib_memset (&new_n_clone->stats_total, 0,
+ sizeof (new_n_clone->stats_total));
+ clib_memset (&new_n_clone->stats_last_clear, 0,
+ sizeof (new_n_clone->stats_last_clear));
}
else
{
diff --git a/src/vlib/threads_cli.c b/src/vlib/threads_cli.c
index 86c02479892..65b3e2a5496 100644
--- a/src/vlib/threads_cli.c
+++ b/src/vlib/threads_cli.c
@@ -168,9 +168,9 @@ trace_frame_queue (vlib_main_t * vm, unformat_input_t * input,
fqt = &fqm->frame_queue_traces[fqix];
fqh = &fqm->frame_queue_histogram[fqix];
- memset (fqt->n_vectors, 0xff, sizeof (fqt->n_vectors));
+ clib_memset (fqt->n_vectors, 0xff, sizeof (fqt->n_vectors));
fqt->written = 0;
- memset (fqh, 0, sizeof (*fqh));
+ clib_memset (fqh, 0, sizeof (*fqh));
fqm->vlib_frame_queues[fqix]->trace = enable;
}
diff --git a/src/vlib/unix/cj.c b/src/vlib/unix/cj.c
index 7757146c7a7..7238dbfac38 100644
--- a/src/vlib/unix/cj.c
+++ b/src/vlib/unix/cj.c
@@ -97,7 +97,7 @@ cj_config (vlib_main_t * vm, unformat_input_t * input)
cjm->num_records = max_pow2 (cjm->num_records);
vec_validate (cjm->records, cjm->num_records - 1);
- memset (cjm->records, 0xff, cjm->num_records * sizeof (cj_record_t));
+ clib_memset (cjm->records, 0xff, cjm->num_records * sizeof (cj_record_t));
cjm->tail = ~0;
cjm->enable = enable;
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index 2fe33cc54fb..56afbc2089b 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -2728,7 +2728,7 @@ unix_cli_file_add (unix_cli_main_t * cm, char *name, int fd)
}
pool_get (cm->cli_file_pool, cf);
- memset (cf, 0, sizeof (*cf));
+ clib_memset (cf, 0, sizeof (*cf));
template.read_function = unix_cli_read_ready;
template.write_function = unix_cli_write_ready;
@@ -2918,7 +2918,7 @@ unix_cli_config (vlib_main_t * vm, unformat_input_t * input)
if (isatty (STDIN_FILENO) && um->cli_line_mode == 0)
{
/* Capture terminal resize events */
- memset (&sa, 0, sizeof (sa));
+ clib_memset (&sa, 0, sizeof (sa));
sa.sa_handler = unix_cli_resize_interrupt;
if (sigaction (SIGWINCH, &sa, 0) < 0)
clib_panic ("sigaction");
diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c
index 24208617fa4..45b12cd5b77 100755
--- a/src/vlib/unix/main.c
+++ b/src/vlib/unix/main.c
@@ -172,7 +172,7 @@ setup_signal_handlers (unix_main_t * um)
for (i = 1; i < 32; i++)
{
- memset (&sa, 0, sizeof (sa));
+ clib_memset (&sa, 0, sizeof (sa));
sa.sa_sigaction = (void *) unix_signal_handler;
sa.sa_flags = SA_SIGINFO;
diff --git a/src/vlib/unix/mc_socket.c b/src/vlib/unix/mc_socket.c
index 1da19a5e773..c820981dae0 100644
--- a/src/vlib/unix/mc_socket.c
+++ b/src/vlib/unix/mc_socket.c
@@ -85,7 +85,7 @@ sendmsg_helper (mc_socket_main_t * msm,
struct msghdr h;
word n_bytes, n_bytes_tx, n_retries;
- memset (&h, 0, sizeof (h));
+ clib_memset (&h, 0, sizeof (h));
h.msg_name = tx_addr;
h.msg_namelen = sizeof (tx_addr[0]);
@@ -146,7 +146,7 @@ tx_ack (void *transport, mc_peer_id_t dest_peer_id, u32 buffer_index)
vlib_main_t *vm = msm->mc_main.vlib_main;
clib_error_t *error;
- memset (&tx_addr, 0, sizeof (tx_addr));
+ clib_memset (&tx_addr, 0, sizeof (tx_addr));
tx_addr.sin_family = AF_INET;
tx_addr.sin_addr.s_addr = mc_socket_peer_id_get_address (dest_peer_id);
tx_addr.sin_port = mc_socket_peer_id_get_port (dest_peer_id);
@@ -197,7 +197,7 @@ recvmsg_helper (mc_socket_main_t * msm,
{
struct msghdr h;
- memset (&h, 0, sizeof (h));
+ clib_memset (&h, 0, sizeof (h));
if (rx_addr)
{
h.msg_name = rx_addr;
@@ -570,7 +570,7 @@ catchup_listen_read_ready (clib_file_t * uf)
clib_file_t template = { 0 };
pool_get (msm->catchups, c);
- memset (c, 0, sizeof (c[0]));
+ clib_memset (c, 0, sizeof (c[0]));
client_len = sizeof (client_addr);
@@ -632,7 +632,7 @@ find_and_bind_to_free_port (word sock, word port)
{
struct sockaddr_in a;
- memset (&a, 0, sizeof (a)); /* Warnings be gone */
+ clib_memset (&a, 0, sizeof (a)); /* Warnings be gone */
a.sin_family = PF_INET;
a.sin_addr.s_addr = INADDR_ANY;
@@ -672,7 +672,7 @@ setup_mutlicast_socket (mc_socket_main_t * msm,
0)
return clib_error_return_unix (0, "%s setsockopt SO_REUSEADDR", type);
- memset (&ms->tx_addr, 0, sizeof (ms->tx_addr));
+ clib_memset (&ms->tx_addr, 0, sizeof (ms->tx_addr));
ms->tx_addr.sin_family = AF_INET;
ms->tx_addr.sin_addr.s_addr =
htonl (msm->multicast_tx_ip4_address_host_byte_order);
@@ -682,7 +682,7 @@ setup_mutlicast_socket (mc_socket_main_t * msm,
sizeof (ms->tx_addr)) < 0)
return clib_error_return_unix (0, "%s bind", type);
- memset (&mcast_req, 0, sizeof (mcast_req));
+ clib_memset (&mcast_req, 0, sizeof (mcast_req));
mcast_req.imr_multiaddr.s_addr =
htonl (msm->multicast_tx_ip4_address_host_byte_order);
mcast_req.imr_interface.s_addr = msm->if_ip4_address_net_byte_order;
@@ -852,7 +852,7 @@ catchup_request_fun (void *transport_main,
int one = 1;
pool_get (msm->catchups, c);
- memset (c, 0, sizeof (*c));
+ clib_memset (c, 0, sizeof (*c));
c->socket = socket (AF_INET, SOCK_STREAM, 0);
if (c->socket < 0)
@@ -867,7 +867,7 @@ catchup_request_fun (void *transport_main,
return 0;
}
- memset (&addr, 0, sizeof (addr));
+ clib_memset (&addr, 0, sizeof (addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = mc_socket_peer_id_get_address (catchup_peer_id);
addr.sin_port = mc_socket_peer_id_get_port (catchup_peer_id);