json: improve json parsing

spa_json_get_string() will never write more than maxlen.
Use spa_json_parse_stringn() to perform destination length checking.
This commit is contained in:
Wim Taymans
2022-01-04 16:36:15 +01:00
parent 071ad0e43f
commit 4896ad0680
3 changed files with 6 additions and 7 deletions

View File

@@ -62,7 +62,7 @@ json_object_find (const char *obj, const char *key, char *value, size_t len)
if (spa_json_enter_object(&it[0], &it[1]) <= 0)
return -EINVAL;
while (spa_json_get_string(&it[1], k, sizeof(k)-1) > 0) {
while (spa_json_get_string(&it[1], k, sizeof(k)) > 0) {
if (strcmp(k, key) == 0) {
if (spa_json_get_string(&it[1], value, len) <= 0)
continue;