mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-07 13:30:03 -05:00
* add validity checking for sample_spec, channel_map and cvolume structures
* return PA_ERR_TOOLARGE when the user tries to upload a over-sized sample * notify the user if uploading a simple faield due to some reason git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@790 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
286310a563
commit
3590ee7581
1 changed files with 15 additions and 2 deletions
|
|
@ -732,6 +732,9 @@ static void command_create_playback_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GC
|
|||
CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
|
||||
CHECK_VALIDITY(c->pstream, name, tag, PA_ERR_ACCESS);
|
||||
CHECK_VALIDITY(c->pstream, sink_index != PA_INVALID_INDEX || !sink_name || *sink_name, tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, pa_channel_map_valid(&map), tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, pa_sample_spec_valid(&ss), tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, pa_cvolume_valid(&volume), tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, map.channels == ss.channels && volume.channels == ss.channels, tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, maxlength <= MAX_MEMBLOCKQ_LENGTH, tag, PA_ERR_INVALID);
|
||||
|
||||
|
|
@ -827,6 +830,8 @@ static void command_create_record_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_
|
|||
|
||||
CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
|
||||
CHECK_VALIDITY(c->pstream, name, tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, pa_sample_spec_valid(&ss), tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, pa_channel_map_valid(&map), tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, source_index != PA_INVALID_INDEX || !source_name || *source_name, tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, map.channels == ss.channels, tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, maxlength <= MAX_MEMBLOCKQ_LENGTH, tag, PA_ERR_INVALID);
|
||||
|
|
@ -1126,7 +1131,11 @@ static void command_create_upload_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_
|
|||
}
|
||||
|
||||
CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
|
||||
CHECK_VALIDITY(c->pstream, pa_sample_spec_valid(&ss), tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, pa_channel_map_valid(&map), tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, map.channels == ss.channels, tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, (length % pa_frame_size(&ss)) == 0 && length > 0, tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, length <= PA_SCACHE_ENTRY_SIZE_MAX, tag, PA_ERR_TOOLARGE);
|
||||
CHECK_VALIDITY(c->pstream, name && *name, tag, PA_ERR_INVALID);
|
||||
|
||||
s = upload_stream_new(c, &ss, &map, name, length);
|
||||
|
|
@ -1157,8 +1166,11 @@ static void command_finish_upload_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_
|
|||
CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_NOENTITY);
|
||||
CHECK_VALIDITY(c->pstream, s->type == UPLOAD_STREAM, tag, PA_ERR_NOENTITY);
|
||||
|
||||
pa_scache_add_item(c->protocol->core, s->name, &s->sample_spec, &s->channel_map, &s->memchunk, &idx);
|
||||
pa_pstream_send_simple_ack(c->pstream, tag);
|
||||
if (pa_scache_add_item(c->protocol->core, s->name, &s->sample_spec, &s->channel_map, &s->memchunk, &idx) < 0)
|
||||
pa_pstream_send_error(c->pstream, tag, PA_ERR_INTERNAL);
|
||||
else
|
||||
pa_pstream_send_simple_ack(c->pstream, tag);
|
||||
|
||||
upload_stream_free(s);
|
||||
}
|
||||
|
||||
|
|
@ -1553,6 +1565,7 @@ static void command_set_volume(
|
|||
|
||||
CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
|
||||
CHECK_VALIDITY(c->pstream, idx != PA_INVALID_INDEX || !name || *name, tag, PA_ERR_INVALID);
|
||||
CHECK_VALIDITY(c->pstream, pa_cvolume_valid(&volume), tag, PA_ERR_INVALID);
|
||||
|
||||
if (command == PA_COMMAND_SET_SINK_VOLUME) {
|
||||
if (idx != PA_INVALID_INDEX)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue