vat: fix static analysis warning

Type: fix
Ticket: VPP-1837

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: Ia46f865082dcf0cf06af99a7c958c4a5b02193ce
This commit is contained in:
Dave Barach
2020-04-06 10:19:18 -04:00
committed by Florin Coras
parent 7a2abce4c9
commit 032a5e3da0

View File

@ -93,8 +93,9 @@ static_always_inline void
vat_json_set_string_copy (vat_json_node_t * json, const u8 * str)
{
u8 *ns = NULL;
vec_validate (ns, strlen ((const char *) str));
strcpy ((char *) ns, (const char *) str);
int len = strlen ((const char *) str);
vec_validate (ns, len);
strncpy ((char *) ns, (const char *) str, len + 1);
vec_add1 (ns, '\0');
vat_json_set_string (json, ns);
}