mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-30 06:46:49 -04:00
spa: add spa_alloca that does overflow and limit checks
Make a function like alloca but with overflow checks and a max allocation size. Use this function where we can and also make sure that all alloca calls are in some way limited.
This commit is contained in:
parent
a9f1ad414e
commit
ed2c0ad4ee
10 changed files with 84 additions and 51 deletions
|
|
@ -560,12 +560,14 @@ static int handle_server_hello(struct client *client, struct spa_json *payload)
|
|||
|
||||
while ((l = spa_json_object_next(payload, key, sizeof(key), &v)) > 0) {
|
||||
if (spa_streq(key, "server_id")) {
|
||||
t = alloca(l+1);
|
||||
if ((t = spa_alloca(1, l+1, 1024)) == NULL)
|
||||
return -errno;
|
||||
spa_json_parse_stringn(v, l, t, l+1);
|
||||
pw_properties_set(client->props, "sendspin.server-id", t);
|
||||
}
|
||||
else if (spa_streq(key, "name")) {
|
||||
t = alloca(l+1);
|
||||
if ((t = spa_alloca(1, l+1, 1024)) == NULL)
|
||||
return -errno;
|
||||
spa_json_parse_stringn(v, l, t, l+1);
|
||||
pw_properties_set(client->props, "sendspin.server-name", t);
|
||||
}
|
||||
|
|
@ -579,7 +581,8 @@ static int handle_server_hello(struct client *client, struct spa_json *payload)
|
|||
|
||||
spa_json_enter(payload, &it[0]);
|
||||
while ((l = spa_json_next(&it[0], &v)) > 0) {
|
||||
t = alloca(l+1);
|
||||
if ((t = spa_alloca(1, l+1, 128)) == NULL)
|
||||
continue;
|
||||
spa_json_parse_stringn(v, l, t, l+1);
|
||||
|
||||
if (spa_streq(t, "player@v1"))
|
||||
|
|
@ -589,7 +592,8 @@ static int handle_server_hello(struct client *client, struct spa_json *payload)
|
|||
}
|
||||
}
|
||||
else if (spa_streq(key, "connection_reason")) {
|
||||
t = alloca(l+1);
|
||||
if ((t = spa_alloca(1, l+1, 4096)) == NULL)
|
||||
return -errno;
|
||||
spa_json_parse_stringn(v, l, t, l+1);
|
||||
|
||||
if (spa_streq(t, "discovery"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue