mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-12 13:30:15 -05:00
json: avoid converting random string to floats
Only allow the json float characters when converting to float. This avoids NAN, INF, 0xffe4 etc to be seen as a json float.
This commit is contained in:
parent
bdfde2fdf0
commit
cbbc4baa3f
2 changed files with 3 additions and 1 deletions
|
|
@ -240,6 +240,8 @@ static inline bool spa_json_is_null(const char *val, int len)
|
|||
static inline int spa_json_parse_float(const char *val, int len, float *result)
|
||||
{
|
||||
char *end;
|
||||
if (strspn(val, "+-0123456789.Ee") < (size_t)len)
|
||||
return 0;
|
||||
*result = spa_strtof(val, &end);
|
||||
return len > 0 && end == val + len;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue