src: check that POD arrays have the correct size for their type

The parser does not check that POD arrays have the correct size for
their type, so the calling code must do that.

This also enumerates some of the code that cannot handle the size of the
values of an array not being the exact expected size for its type.
There is a lot of it.
This commit is contained in:
Demi Marie Obenour 2025-07-20 15:06:49 -04:00
parent 0f6b365138
commit 9e789c65c2
4 changed files with 32 additions and 21 deletions

View file

@ -977,7 +977,7 @@ static int device_demarshal_subscribe_params(void *object, const struct pw_proto
SPA_POD_Array(&csize, &ctype, &n_ids, &ids)) < 0)
return -EINVAL;
if (ctype != SPA_TYPE_Id)
if (ctype != SPA_TYPE_Id || csize != sizeof(uint32_t))
return -EINVAL;
return pw_resource_notify(resource, struct pw_device_methods, subscribe_params, 0,
@ -1238,7 +1238,7 @@ static int node_demarshal_subscribe_params(void *object, const struct pw_protoco
SPA_POD_Array(&csize, &ctype, &n_ids, &ids)) < 0)
return -EINVAL;
if (ctype != SPA_TYPE_Id)
if (ctype != SPA_TYPE_Id || csize != sizeof(uint32_t))
return -EINVAL;
return pw_resource_notify(resource, struct pw_node_methods, subscribe_params, 0,
@ -1462,7 +1462,7 @@ static int port_demarshal_subscribe_params(void *object, const struct pw_protoco
SPA_POD_Array(&csize, &ctype, &n_ids, &ids)) < 0)
return -EINVAL;
if (ctype != SPA_TYPE_Id)
if (ctype != SPA_TYPE_Id || csize != sizeof(uint32_t))
return -EINVAL;
return pw_resource_notify(resource, struct pw_port_methods, subscribe_params, 0,