diff options
| author | Lennart Poettering <lennart@poettering.net> | 2006-04-23 21:01:44 +0000 | 
|---|---|---|
| committer | Lennart Poettering <lennart@poettering.net> | 2006-04-23 21:01:44 +0000 | 
| commit | 3590ee7581df02152cb2924509752565cd1e3dea (patch) | |
| tree | 468bb20aee277fedf807e169ce2be2618d211717 | |
| parent | 286310a563ad52105676243326b6ec2c34d945c5 (diff) | |
* 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
| -rw-r--r-- | src/polypcore/protocol-native.c | 17 | 
1 files changed, 15 insertions, 2 deletions
| diff --git a/src/polypcore/protocol-native.c b/src/polypcore/protocol-native.c index f8c2d166..ace9db6f 100644 --- a/src/polypcore/protocol-native.c +++ b/src/polypcore/protocol-native.c @@ -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) | 
