diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2019-07-17 16:15:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-17 16:15:12 +0000 |
commit | a645b9129ae845caa4556e0f86392bd8d1343adf (patch) | |
tree | 771568f0f50294a3d321fe4bda347263b6942c6d /libnetdata | |
parent | 0cf35dc906a97d8efc841abe331433066503a925 (diff) |
json function could create overflow (#6460)
* jsonfix
The use of sprintf to copy from a name to other name could create
overflow, because source and destination have the same size, to avoid
this I am changing the sprintf to snprintf'
* jsonfix
Use internal netdata snprintfz instead snprintf
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/json/json.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libnetdata/json/json.c b/libnetdata/json/json.c index c9ff39b056..7c5adca3db 100644 --- a/libnetdata/json/json.c +++ b/libnetdata/json/json.c @@ -319,8 +319,8 @@ size_t json_walk_array(char *js, jsmntok_t *t, size_t nest, size_t start, JSON_E info("JSON: JSON walk_array ignoring element with name:%s fullname:%s",e->name, e->fullname); continue; } - sprintf(ne.name, "%s[%lu]", e->name, i); - sprintf(ne.fullname, "%s[%lu]", e->fullname, i); + snprintfz(ne.name, JSON_NAME_LEN, "%s[%lu]", e->name, i); + snprintfz(ne.fullname, JSON_FULLNAME_LEN, "%s[%lu]", e->fullname, i); switch(t[start].type) { case JSMN_PRIMITIVE: |