mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-04 06:46:24 -04:00
*: more type checks for POD
Check that POD is correctly typed before using it.
This commit is contained in:
parent
a50b66651e
commit
c64a34d93f
20 changed files with 67 additions and 28 deletions
|
|
@ -1657,6 +1657,9 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
|||
|
||||
spa_zero(vrp);
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
switch (prop->key) {
|
||||
case SPA_PROP_volume:
|
||||
|
|
@ -1827,7 +1830,9 @@ static int apply_midi(struct impl *this, const struct spa_pod *value)
|
|||
uint8_t data[8];
|
||||
int size;
|
||||
|
||||
size = spa_ump_to_midi(SPA_POD_BODY(value), SPA_POD_BODY_SIZE(value),
|
||||
if (!spa_pod_is_bytes(value))
|
||||
return -EINVAL;
|
||||
size = spa_ump_to_midi(SPA_POD_BODY(value), value->size,
|
||||
data, sizeof(data));
|
||||
if (size < 3)
|
||||
return -EINVAL;
|
||||
|
|
@ -1973,7 +1978,8 @@ static int node_set_param_props(struct impl *this, uint32_t flags,
|
|||
|
||||
if (param == NULL)
|
||||
return 0;
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
this->filter_props_count = 0;
|
||||
|
||||
spa_list_for_each_safe(g, t, &this->active_graphs, link) {
|
||||
|
|
|
|||
|
|
@ -251,13 +251,19 @@ static int apply_props(struct impl *this, const struct spa_pod *param)
|
|||
struct props *p = &this->props;
|
||||
int changed = 0;
|
||||
|
||||
if (!spa_pod_is_object_type(param, SPA_TYPE_OBJECT_Props))
|
||||
return -EINVAL;
|
||||
SPA_POD_OBJECT_FOREACH(obj, prop) {
|
||||
switch (prop->key) {
|
||||
case SPA_PROP_volume:
|
||||
if (!spa_pod_is_float(&prop->value))
|
||||
return -EINVAL;
|
||||
if (spa_pod_get_float(&prop->value, &p->volume) == 0)
|
||||
changed++;
|
||||
break;
|
||||
case SPA_PROP_mute:
|
||||
if (!spa_pod_is_bool(&prop->value))
|
||||
return -EINVAL;
|
||||
if (spa_pod_get_bool(&prop->value, &p->mute) == 0)
|
||||
changed++;
|
||||
break;
|
||||
|
|
@ -272,6 +278,7 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
const struct spa_pod *param)
|
||||
{
|
||||
struct impl *this = object;
|
||||
int res;
|
||||
|
||||
spa_return_val_if_fail(this != NULL, -EINVAL);
|
||||
|
||||
|
|
@ -281,7 +288,9 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
props_reset(&this->props);
|
||||
return 0;
|
||||
}
|
||||
if (apply_props(this, param) > 0) {
|
||||
if ((res = apply_props(this, param)) < 0)
|
||||
return res;
|
||||
if (res > 0) {
|
||||
this->info.change_mask = SPA_NODE_CHANGE_MASK_PARAMS;
|
||||
this->params[1].flags ^= SPA_PARAM_INFO_SERIAL;
|
||||
emit_info(this, false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue