mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-02-07 04:06:12 -05:00
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:
parent
0f6b365138
commit
9e789c65c2
4 changed files with 32 additions and 21 deletions
|
|
@ -369,7 +369,9 @@ uint32_t collect_port_info(struct pw_manager_object *card, struct card_info *car
|
|||
|
||||
n = 0;
|
||||
spa_list_for_each(p, &card->param_list, link) {
|
||||
struct spa_pod *devices = NULL, *profiles = NULL;
|
||||
int32_t *devices = NULL, *profiles = NULL;
|
||||
uint32_t devices_size = 0, devices_type = 0, n_devices = 0;
|
||||
uint32_t profiles_size = 0, profiles_type = 0, n_profiles = 0;
|
||||
struct port_info *pi;
|
||||
|
||||
if (p->id != SPA_PARAM_EnumRoute)
|
||||
|
|
@ -387,16 +389,24 @@ uint32_t collect_port_info(struct pw_manager_object *card, struct card_info *car
|
|||
SPA_PARAM_ROUTE_priority, SPA_POD_OPT_Int(&pi->priority),
|
||||
SPA_PARAM_ROUTE_available, SPA_POD_OPT_Id(&pi->available),
|
||||
SPA_PARAM_ROUTE_info, SPA_POD_OPT_Pod(&pi->info),
|
||||
SPA_PARAM_ROUTE_devices, SPA_POD_OPT_Pod(&devices),
|
||||
SPA_PARAM_ROUTE_profiles, SPA_POD_OPT_Pod(&profiles)) < 0)
|
||||
SPA_PARAM_ROUTE_devices, SPA_POD_OPT_Array(&devices_size,
|
||||
&devices_type, &n_devices, &devices),
|
||||
SPA_PARAM_ROUTE_profiles, SPA_POD_OPT_Array(&profiles_size,
|
||||
&profiles_type, &n_profiles, &profiles)) < 0)
|
||||
continue;
|
||||
|
||||
if (pi->description == NULL)
|
||||
pi->description = pi->name;
|
||||
if (devices)
|
||||
pi->devices = spa_pod_get_array(devices, &pi->n_devices);
|
||||
if (profiles)
|
||||
pi->profiles = spa_pod_get_array(profiles, &pi->n_profiles);
|
||||
if (devices && devices_size == sizeof(pi->devices[0]) &&
|
||||
devices_type == SPA_TYPE_Int) {
|
||||
pi->devices = devices;
|
||||
pi->n_devices = n_devices;
|
||||
}
|
||||
if (profiles && profiles_size == sizeof(pi->profiles[0]) &&
|
||||
profiles_type == SPA_TYPE_Int) {
|
||||
pi->profiles = profiles;
|
||||
pi->n_profiles = n_profiles;
|
||||
}
|
||||
|
||||
if (dev_info != NULL) {
|
||||
if (pi->direction != dev_info->direction)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue