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/vnet/policer/policer_api.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/vnet/policer/policer_api.c') diff --git a/src/vnet/policer/policer_api.c b/src/vnet/policer/policer_api.c index 3dc2cdd6a0a..686ed508a59 100644 --- a/src/vnet/policer/policer_api.c +++ b/src/vnet/policer/policer_api.c @@ -58,6 +58,7 @@ vl_api_policer_add_del_t_handler (vl_api_policer_add_del_t * mp) u32 policer_index; name = format (0, "%s", mp->name); + vec_terminate_c_string (name); memset (&cfg, 0, sizeof (cfg)); cfg.rfc = mp->type; @@ -152,6 +153,7 @@ vl_api_policer_dump_t_handler (vl_api_policer_dump_t * mp) if (mp->match_name_valid) { match_name = format (0, "%s%c", mp->match_name, 0); + vec_terminate_c_string (match_name); } if (mp->match_name_valid) -- cgit 1.2.3-korg