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
This commit is contained in:
thiagoftsm 2019-07-17 16:15:12 +00:00 committed by GitHub
parent 0cf35dc906
commit a645b9129a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -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: