From e1ce365cd9cdcdfd1535aa58882de249c6274ed4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 29 Aug 2009 06:11:02 +0200 Subject: native: make sure clients cannot trigger an assert by sending us invalid volume info --- src/pulsecore/protocol-native.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index a5e952a3..179e62e2 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3390,12 +3390,18 @@ static void command_set_volume( client_name = pa_strnull(pa_proplist_gets(c->client->proplist, PA_PROP_APPLICATION_PROCESS_BINARY)); if (sink) { + CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &sink->sample_spec), tag, PA_ERR_INVALID); + pa_log_debug("Client %s changes volume of sink %s.", client_name, sink->name); pa_sink_set_volume(sink, &volume, TRUE, TRUE); } else if (source) { + CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &source->sample_spec), tag, PA_ERR_INVALID); + pa_log_debug("Client %s changes volume of source %s.", client_name, source->name); pa_source_set_volume(source, &volume, TRUE); } else if (si) { + CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &si->sample_spec), tag, PA_ERR_INVALID); + pa_log_debug("Client %s changes volume of sink input %s.", client_name, pa_strnull(pa_proplist_gets(si->proplist, PA_PROP_MEDIA_NAME))); @@ -3441,7 +3447,6 @@ static void command_set_mute( switch (command) { case PA_COMMAND_SET_SINK_MUTE: - if (idx != PA_INVALID_INDEX) sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx); else -- cgit From 2970c11902b46414d9ff28db1e850d94b137157c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 31 Aug 2009 21:40:59 +0200 Subject: core: always allow volume setting with single-channel pa_cvolume --- src/pulsecore/protocol-native.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 179e62e2..d961dba2 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -3390,17 +3390,17 @@ static void command_set_volume( client_name = pa_strnull(pa_proplist_gets(c->client->proplist, PA_PROP_APPLICATION_PROCESS_BINARY)); if (sink) { - CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &sink->sample_spec), tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &sink->sample_spec), tag, PA_ERR_INVALID); pa_log_debug("Client %s changes volume of sink %s.", client_name, sink->name); pa_sink_set_volume(sink, &volume, TRUE, TRUE); } else if (source) { - CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &source->sample_spec), tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &source->sample_spec), tag, PA_ERR_INVALID); pa_log_debug("Client %s changes volume of source %s.", client_name, source->name); pa_source_set_volume(source, &volume, TRUE); } else if (si) { - CHECK_VALIDITY(c->pstream, pa_cvolume_compatible(&volume, &si->sample_spec), tag, PA_ERR_INVALID); + CHECK_VALIDITY(c->pstream, volume.channels == 1 || pa_cvolume_compatible(&volume, &si->sample_spec), tag, PA_ERR_INVALID); pa_log_debug("Client %s changes volume of sink input %s.", client_name, -- cgit From f5046759cdd72daf5ba3b31c9dfc7b8d5be6bc9b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2009 23:46:23 +0200 Subject: llvm-clang-analyzer: drop a few unnecessary assignments and other trivial fixes --- src/pulsecore/protocol-native.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index d961dba2..0215c233 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -628,7 +628,6 @@ static record_stream* record_stream_new( record_stream *s; pa_source_output *source_output = NULL; - size_t base; pa_source_output_new_data data; pa_assert(c); @@ -682,7 +681,7 @@ static record_stream* record_stream_new( 0, s->buffer_attr.maxlength, 0, - base = pa_frame_size(&source_output->sample_spec), + pa_frame_size(&source_output->sample_spec), 1, 0, 0, -- cgit From 31d1d9088e18b9d59a259230e0e49e6a5908586a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2009 23:53:28 +0200 Subject: protocol-native: log explicitly when someone asks us to quit --- src/pulsecore/protocol-native.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 0215c233..17aee4b1 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -2273,6 +2273,8 @@ static void command_exit(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta ret = pa_core_exit(c->protocol->core, FALSE, 0); CHECK_VALIDITY(c->pstream, ret >= 0, tag, PA_ERR_ACCESS); + pa_log_debug("Client %s asks us to terminate.", pa_strnull(pa_proplist_gets(c->client->proplist, PA_PROP_APPLICATION_PROCESS_BINARY))); + pa_pstream_send_simple_ack(c->pstream, tag); /* nonsense */ } -- cgit From 807f2a9923572a8d88e10672d0cb5886688bb9ff Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 10 Sep 2009 02:15:12 +0200 Subject: native: send PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED messages only to clients that understand it --- src/pulsecore/protocol-native.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/pulsecore/protocol-native.c') diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 17aee4b1..d06dd4eb 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -826,24 +826,26 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata, pa_pstream_send_simple_ack(s->connection->pstream, PA_PTR_TO_UINT(userdata)); break; - case PLAYBACK_STREAM_MESSAGE_UPDATE_TLENGTH: { - pa_tagstruct *t; + case PLAYBACK_STREAM_MESSAGE_UPDATE_TLENGTH: s->buffer_attr.tlength = (uint32_t) offset; - t = pa_tagstruct_new(NULL, 0); - pa_tagstruct_putu32(t, PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED); - pa_tagstruct_putu32(t, (uint32_t) -1); /* tag */ - pa_tagstruct_putu32(t, s->index); - pa_tagstruct_putu32(t, s->buffer_attr.maxlength); - pa_tagstruct_putu32(t, s->buffer_attr.tlength); - pa_tagstruct_putu32(t, s->buffer_attr.prebuf); - pa_tagstruct_putu32(t, s->buffer_attr.minreq); - pa_tagstruct_put_usec(t, s->configured_sink_latency); - pa_pstream_send_tagstruct(s->connection->pstream, t); + if (s->connection->version >= 15) { + pa_tagstruct *t; + + t = pa_tagstruct_new(NULL, 0); + pa_tagstruct_putu32(t, PA_COMMAND_PLAYBACK_BUFFER_ATTR_CHANGED); + pa_tagstruct_putu32(t, (uint32_t) -1); /* tag */ + pa_tagstruct_putu32(t, s->index); + pa_tagstruct_putu32(t, s->buffer_attr.maxlength); + pa_tagstruct_putu32(t, s->buffer_attr.tlength); + pa_tagstruct_putu32(t, s->buffer_attr.prebuf); + pa_tagstruct_putu32(t, s->buffer_attr.minreq); + pa_tagstruct_put_usec(t, s->configured_sink_latency); + pa_pstream_send_tagstruct(s->connection->pstream, t); + } break; - } } return 0; -- cgit