summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2020-04-06 10:19:18 -0400
committerFlorin Coras <florin.coras@gmail.com>2020-04-06 17:26:05 +0000
commit032a5e3da0f4350390d97d6011160fe0d34a8d6e (patch)
treee20253817a3abb3ff6c84e903c39015a687db748 /src
parent7a2abce4c9fc2191b3d3989c84516391036b6882 (diff)
vat: fix static analysis warning
Type: fix Ticket: VPP-1837 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Ia46f865082dcf0cf06af99a7c958c4a5b02193ce
Diffstat (limited to 'src')
-rw-r--r--src/vat/json_format.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/vat/json_format.h b/src/vat/json_format.h
index 154fb3df04b..d2fab9020b3 100644
--- a/src/vat/json_format.h
+++ b/src/vat/json_format.h
@@ -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);
}