From 2dbee9361e74d03727a8b618ba80a5e28c006011 Mon Sep 17 00:00:00 2001 From: Jakub Grajciar Date: Fri, 7 Feb 2020 11:30:26 +0100 Subject: api: improve api string safety - Remove vl_api_from_api_string to prevent use of not nul-terminated strings. - Rename vl_api_from_api_to_vec -> vl_api_from_api_to_new_vec to imply a new vector is created. NOT nul terminated. - Add vl_api_from_api_to_new_c_string. Returns nul terminated string in a new vector. - Add vl_api_c_string_to_api_string. Convert nul terminated string to vl_api_string_t - Add vl_api_vec_to_api_string. Convert NON nul terminated vector to vl_api_string_t Type: fix Signed-off-by: Jakub Grajciar Change-Id: Iadd59b612c0d960a34ad0dd07a9d17f56435c6ea Signed-off-by: Jakub Grajciar --- src/plugins/memif/memif_test.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/plugins/memif') diff --git a/src/plugins/memif/memif_test.c b/src/plugins/memif/memif_test.c index 05f5c29b957..1ec6703d135 100644 --- a/src/plugins/memif/memif_test.c +++ b/src/plugins/memif/memif_test.c @@ -112,9 +112,7 @@ api_memif_socket_filename_add_del (vat_main_t * vam) mp->is_add = is_add; mp->socket_id = htonl (socket_id); char *p = (char *) &mp->socket_filename; - p += - vl_api_to_api_string (strlen ((char *) socket_filename), - (char *) socket_filename, (vl_api_string_t *) p); + p += vl_api_vec_to_api_string (socket_filename, (vl_api_string_t *) p); vec_free (socket_filename); @@ -218,8 +216,7 @@ api_memif_create (vat_main_t * vam) if (secret != 0) { char *p = (char *) &mp->secret; - p += vl_api_to_api_string (strlen ((char *) secret), (char *) secret, - (vl_api_string_t *) p); + p += vl_api_vec_to_api_string (secret, (vl_api_string_t *) p); vec_free (secret); } memcpy (mp->hw_addr, hw_addr, 6); -- cgit 1.2.3-korg