From b88566498a83209f8646e4a6b1d247e69dae2aeb Mon Sep 17 00:00:00 2001 From: Dave Wallace Date: Mon, 31 Jul 2017 13:33:11 -0400 Subject: ssvm->name must be a vector containing a c-string. Change-Id: I14a97a7fdd000da62d2ed4bea71f55ee34a21311 Signed-off-by: Dave Wallace --- src/svm/ssvm.c | 2 ++ src/svm/svm_fifo_segment.c | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/svm') diff --git a/src/svm/ssvm.c b/src/svm/ssvm.c index 23e3cf44..e56e6b45 100644 --- a/src/svm/ssvm.c +++ b/src/svm/ssvm.c @@ -32,6 +32,7 @@ ssvm_master_init (ssvm_private_t * ssvm, u32 master_index) if (CLIB_DEBUG > 1) clib_warning ("[%d] creating segment '%s'", getpid (), ssvm->name); + ASSERT (vec_c_string_is_terminated (ssvm->name)); ssvm_filename = format (0, "/dev/shm/%s%c", ssvm->name, 0); unlink ((char *) ssvm_filename); @@ -110,6 +111,7 @@ ssvm_slave_init (ssvm_private_t * ssvm, int timeout_in_seconds) int ssvm_fd = -1; ssvm_shared_header_t *sh; + ASSERT (vec_c_string_is_terminated (ssvm->name)); ssvm->i_am_master = 0; while (timeout_in_seconds-- > 0) diff --git a/src/svm/svm_fifo_segment.c b/src/svm/svm_fifo_segment.c index a01e26e4..86661e51 100644 --- a/src/svm/svm_fifo_segment.c +++ b/src/svm/svm_fifo_segment.c @@ -105,7 +105,7 @@ svm_fifo_segment_create (svm_fifo_segment_create_args_t * a) s->ssvm.ssvm_size = a->segment_size; s->ssvm.i_am_master = 1; s->ssvm.my_pid = getpid (); - s->ssvm.name = format (0, "%s", a->segment_name); + s->ssvm.name = format (0, "%s%c", a->segment_name, 0); s->ssvm.requested_va = sm->next_baseva; rv = ssvm_master_init (&s->ssvm, s - sm->segments); @@ -192,7 +192,7 @@ svm_fifo_segment_create_process_private (svm_fifo_segment_create_args_t * a) s->ssvm.ssvm_size = ~0; s->ssvm.i_am_master = 1; s->ssvm.my_pid = getpid (); - s->ssvm.name = (u8 *) a->segment_name; + s->ssvm.name = format (0, "%s%c", a->segment_name, 0); s->ssvm.requested_va = ~0; /* Allocate a [sic] shared memory header, in process memory... */ @@ -240,7 +240,7 @@ svm_fifo_segment_attach (svm_fifo_segment_create_args_t * a) s->ssvm.ssvm_size = a->segment_size; s->ssvm.my_pid = getpid (); - s->ssvm.name = (u8 *) a->segment_name; + s->ssvm.name = format (0, "%s%c", a->segment_name, 0); s->ssvm.requested_va = sm->next_baseva; rv = ssvm_slave_init (&s->ssvm, sm->timeout_in_seconds); -- cgit 1.2.3-korg