mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-16 07:00:00 -05:00
json: handle overflow better
We need at least the length of the string+1 as the length of the target in spa_json_get_string(). Add a unit test for this.
This commit is contained in:
parent
fc9a6d6b1e
commit
db85339f50
2 changed files with 18 additions and 1 deletions
|
|
@ -351,7 +351,7 @@ static inline int spa_json_get_string(struct spa_json *iter, char *res, int maxl
|
|||
{
|
||||
const char *value;
|
||||
int len;
|
||||
if ((len = spa_json_next(iter, &value)) <= 0 || maxlen < len)
|
||||
if ((len = spa_json_next(iter, &value)) <= 0 || maxlen <= len)
|
||||
return -1;
|
||||
return spa_json_parse_string(value, len, res);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue