Code Review
/
vpp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
review
|
tree
raw
|
patch
| inline |
side by side
(parent:
3d57cfd
)
vat: fix static analysis warning
80/28380/1
author
Dave Barach
<dave@barachs.net>
Mon, 6 Apr 2020 14:19:18 +0000
(10:19 -0400)
committer
Andrew Yourtchenko
<ayourtch@gmail.com>
Thu, 13 Aug 2020 17:20:47 +0000
(17:20 +0000)
Type: fix
Ticket: VPP-1837
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: Ia46f865082dcf0cf06af99a7c958c4a5b02193ce
(cherry picked from commit
032a5e3da0f4350390d97d6011160fe0d34a8d6e
)
src/vat/json_format.h
patch
|
blob
|
history
diff --git
a/src/vat/json_format.h
b/src/vat/json_format.h
index
154fb3d
..
d2fab90
100644
(file)
--- 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);
}