summaryrefslogtreecommitdiffstats
path: root/src/vnet/lisp-cp/one_api.c
diff options
context:
space:
mode:
authorGabriel Ganne <gabriel.ganne@enea.com>2017-10-19 15:10:46 +0200
committerChris Luke <chris_luke@comcast.com>2017-10-20 11:32:31 +0000
commit3491d7f1d05ee5e05ebf0f6129d54c5ca85e22cf (patch)
tree28f7f1a72f41e4304c26986803ffef20a06eceb2 /src/vnet/lisp-cp/one_api.c
parent470a011511a41dcb893df12b33261030717d1e08 (diff)
null-terminate some formatted string
Any u8* variable created by format() is NOT null-terminated. Add the null terminating byte with vec_terminate_c_string(). If that variable is used by (at least) hash_get_mem(), then it needs to be null-terminated, as it will go through string_key_sum() which makes a call to strlen. Change-Id: I4e51e1b6668f557e53af3bb897cd281598eedbc0 Signed-off-by: Gabriel Ganne <gabriel.ganne@enea.com>
Diffstat (limited to 'src/vnet/lisp-cp/one_api.c')
-rw-r--r--src/vnet/lisp-cp/one_api.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/vnet/lisp-cp/one_api.c b/src/vnet/lisp-cp/one_api.c
index e3a2afe78cf..c9b5dca3aff 100644
--- a/src/vnet/lisp-cp/one_api.c
+++ b/src/vnet/lisp-cp/one_api.c
@@ -203,6 +203,7 @@ vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
memset (a, 0, sizeof (a[0]));
locator_name = format (0, "%s", mp->locator_set_name);
+ vec_terminate_c_string (locator_name);
a->name = locator_name;
a->is_add = mp->is_add;
@@ -257,6 +258,7 @@ vl_api_one_add_del_locator_t_handler (vl_api_one_add_del_locator_t * mp)
vec_add1 (locators, locator);
locator_name = format (0, "%s", mp->locator_set_name);
+ vec_terminate_c_string (locator_name);
a->name = locator_name;
a->locators = locators;
@@ -343,6 +345,7 @@ vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
}
name = format (0, "%s", mp->locator_set_name);
+ vec_terminate_c_string (name);
p = hash_get_mem (lcm->locator_set_index_by_name, name);
if (!p)
{
@@ -483,6 +486,7 @@ vl_api_one_nsh_set_locator_set_t_handler (vl_api_one_nsh_set_locator_set_t
u8 *ls_name = 0;
ls_name = format (0, "%s", mp->ls_name);
+ vec_terminate_c_string (ls_name);
rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
vec_free (ls_name);
@@ -498,6 +502,7 @@ vl_api_one_pitr_set_locator_set_t_handler (vl_api_one_pitr_set_locator_set_t
u8 *ls_name = 0;
ls_name = format (0, "%s", mp->ls_name);
+ vec_terminate_c_string (ls_name);
rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
vec_free (ls_name);
@@ -585,6 +590,7 @@ static void
vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
locator_set_name = format (0, "%s", mp->locator_set_name);
+ vec_terminate_c_string (locator_set_name);
a->is_add = mp->is_add;
a->locator_set_name = locator_set_name;
@@ -728,6 +734,7 @@ vl_api_one_locator_dump_t_handler (vl_api_one_locator_dump_t * mp)
/* make sure we get a proper C-string */
mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
ls_name = format (0, "%s", mp->ls_name);
+ vec_terminate_c_string (ls_name);
p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
if (!p)
goto out;