]> code.delx.au - pulseaudio/commitdiff
native: make sure clients cannot trigger an assert by sending us invalid volume info
authorLennart Poettering <lennart@poettering.net>
Sat, 29 Aug 2009 04:11:02 +0000 (06:11 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 29 Aug 2009 04:11:02 +0000 (06:11 +0200)
src/pulsecore/protocol-native.c

index a5e952a3c04cef000ce73bc950f24c638b340ac6..179e62e276dcfb5749561a90b01f85745ace9054 100644 (file)
@@ -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