From 3491d7f1d05ee5e05ebf0f6129d54c5ca85e22cf Mon Sep 17 00:00:00 2001 From: Gabriel Ganne Date: Thu, 19 Oct 2017 15:10:46 +0200 Subject: 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 --- src/vpp/api/api.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/vpp/api/api.c') diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c index 7350936d061..36953aec623 100644 --- a/src/vpp/api/api.c +++ b/src/vpp/api/api.c @@ -1805,6 +1805,7 @@ vl_api_pg_capture_t_handler (vl_api_pg_capture_t * mp) vnet_hw_interface_t *hi = 0; u8 *intf_name = format (0, "pg%d", ntohl (mp->interface_id), 0); + vec_terminate_c_string (intf_name); u32 hw_if_index = ~0; uword *p = hash_get_mem (im->hw_interface_by_name, intf_name); if (p) @@ -2109,6 +2110,9 @@ vl_api_feature_enable_disable_t_handler (vl_api_feature_enable_disable_t * mp) u8 *arc_name = format (0, "%s%c", mp->arc_name, 0); u8 *feature_name = format (0, "%s%c", mp->feature_name, 0); + vec_terminate_c_string (arc_name); + vec_terminate_c_string (feature_name); + vnet_feature_registration_t *reg = vnet_get_feature_reg ((const char *) arc_name, (const char *) feature_name); -- cgit 1.2.3-korg