mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
add a few additional validity checks
This commit is contained in:
parent
83ddc0936e
commit
12b735962a
2 changed files with 43 additions and 6 deletions
|
|
@ -30,6 +30,7 @@
|
||||||
#include <pulsecore/pstream-util.h>
|
#include <pulsecore/pstream-util.h>
|
||||||
|
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include "operation.h"
|
||||||
|
|
||||||
#include "ext-stream-restore.h"
|
#include "ext-stream-restore.h"
|
||||||
|
|
||||||
|
|
@ -191,8 +192,8 @@ pa_operation *pa_ext_stream_restore_write(
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
pa_operation *o;
|
pa_operation *o = NULL;
|
||||||
pa_tagstruct *t;
|
pa_tagstruct *t = NULL;
|
||||||
|
|
||||||
pa_assert(c);
|
pa_assert(c);
|
||||||
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
pa_assert(PA_REFCNT_VALUE(c) >= 1);
|
||||||
|
|
@ -213,7 +214,15 @@ pa_operation *pa_ext_stream_restore_write(
|
||||||
pa_tagstruct_put_boolean(t, apply_immediately);
|
pa_tagstruct_put_boolean(t, apply_immediately);
|
||||||
|
|
||||||
for (; n > 0; n--, data++) {
|
for (; n > 0; n--, data++) {
|
||||||
|
if (!data->name || !*data->name)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
pa_tagstruct_puts(t, data->name);
|
pa_tagstruct_puts(t, data->name);
|
||||||
|
|
||||||
|
if (data->volume.channels > 0 &&
|
||||||
|
!pa_cvolume_compatible_with_channel_map(&data->volume, &data->channel_map))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
pa_tagstruct_put_channel_map(t, &data->channel_map);
|
pa_tagstruct_put_channel_map(t, &data->channel_map);
|
||||||
pa_tagstruct_put_cvolume(t, &data->volume);
|
pa_tagstruct_put_cvolume(t, &data->volume);
|
||||||
pa_tagstruct_puts(t, data->device);
|
pa_tagstruct_puts(t, data->device);
|
||||||
|
|
@ -224,6 +233,18 @@ pa_operation *pa_ext_stream_restore_write(
|
||||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (o) {
|
||||||
|
pa_operation_cancel(o);
|
||||||
|
pa_operation_unref(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t)
|
||||||
|
pa_tagstruct_free(t);
|
||||||
|
|
||||||
|
pa_context_set_error(c, PA_ERR_INVALID);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_operation *pa_ext_stream_restore_delete(
|
pa_operation *pa_ext_stream_restore_delete(
|
||||||
|
|
@ -233,8 +254,8 @@ pa_operation *pa_ext_stream_restore_delete(
|
||||||
void *userdata) {
|
void *userdata) {
|
||||||
|
|
||||||
uint32_t tag;
|
uint32_t tag;
|
||||||
pa_operation *o;
|
pa_operation *o = NULL;
|
||||||
pa_tagstruct *t;
|
pa_tagstruct *t = NULL;
|
||||||
const char *const *k;
|
const char *const *k;
|
||||||
|
|
||||||
pa_assert(c);
|
pa_assert(c);
|
||||||
|
|
@ -251,13 +272,29 @@ pa_operation *pa_ext_stream_restore_delete(
|
||||||
pa_tagstruct_puts(t, "module-stream-restore");
|
pa_tagstruct_puts(t, "module-stream-restore");
|
||||||
pa_tagstruct_putu32(t, SUBCOMMAND_DELETE);
|
pa_tagstruct_putu32(t, SUBCOMMAND_DELETE);
|
||||||
|
|
||||||
for (k = s; *k; k++)
|
for (k = s; *k; k++) {
|
||||||
|
if (!*k || !**k)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
pa_tagstruct_puts(t, *k);
|
pa_tagstruct_puts(t, *k);
|
||||||
|
}
|
||||||
|
|
||||||
pa_pstream_send_tagstruct(c->pstream, t);
|
pa_pstream_send_tagstruct(c->pstream, t);
|
||||||
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
if (o) {
|
||||||
|
pa_operation_cancel(o);
|
||||||
|
pa_operation_unref(o);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t)
|
||||||
|
pa_tagstruct_free(t);
|
||||||
|
|
||||||
|
pa_context_set_error(c, PA_ERR_INVALID);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_operation *pa_ext_stream_restore_subscribe(
|
pa_operation *pa_ext_stream_restore_subscribe(
|
||||||
|
|
@ -322,5 +359,4 @@ void pa_ext_stream_restore_command(pa_context *c, uint32_t tag, pa_tagstruct *t)
|
||||||
|
|
||||||
if (c->ext_stream_restore.callback)
|
if (c->ext_stream_restore.callback)
|
||||||
c->ext_stream_restore.callback(c, c->ext_stream_restore.userdata);
|
c->ext_stream_restore.callback(c, c->ext_stream_restore.userdata);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ pa_operation *pa_operation_ref(pa_operation *o) {
|
||||||
PA_REFCNT_INC(o);
|
PA_REFCNT_INC(o);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa_operation_unref(pa_operation *o) {
|
void pa_operation_unref(pa_operation *o) {
|
||||||
pa_assert(o);
|
pa_assert(o);
|
||||||
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
pa_assert(PA_REFCNT_VALUE(o) >= 1);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue