summaryrefslogtreecommitdiff
path: root/src/combined/demux_wavpack.c
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-02-25 17:52:16 +0000
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-02-25 17:52:16 +0000
commit12ebf363662fc26599ca0ee5a34f2c622f2362a7 (patch)
treeaf86a7db683548aed93ba73e4d9a7b30df3089e9 /src/combined/demux_wavpack.c
parentdd68f6fecd2f8f1195747d7afcbe62c958440ba0 (diff)
downloadxine-lib-12ebf363662fc26599ca0ee5a34f2c622f2362a7.tar.gz
xine-lib-12ebf363662fc26599ca0ee5a34f2c622f2362a7.tar.bz2
Use a bitmask, and ensure that the values reported by wavpack for bits_per_sample and channels (that have sane limits) are inside the boundaries, this way we don't end up eating memory in the case of a malformed wavpack file. While we're at it, also try to compact the size of the wavpack structures.
CVS patchset: 8623 CVS date: 2007/02/25 17:52:16
Diffstat (limited to 'src/combined/demux_wavpack.c')
-rw-r--r--src/combined/demux_wavpack.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/combined/demux_wavpack.c b/src/combined/demux_wavpack.c
index bb43a590c..6f5cf68ff 100644
--- a/src/combined/demux_wavpack.c
+++ b/src/combined/demux_wavpack.c
@@ -19,7 +19,7 @@
*
* xine interface to libwavpack by Diego Pettenò <flameeyes@gmail.com>
*
- * $Id: demux_wavpack.c,v 1.8 2007/02/25 17:34:48 dgp85 Exp $
+ * $Id: demux_wavpack.c,v 1.9 2007/02/25 17:52:16 dgp85 Exp $
*/
#define LOG_MODULE "demux_wavpack"
@@ -46,8 +46,8 @@ typedef struct {
uint32_t current_sample;
uint32_t samples;
uint32_t samplerate;
- uint32_t bits_per_sample;
- uint32_t channels;
+ uint16_t bits_per_sample:6;
+ uint16_t channels:4;
} demux_wv_t;
typedef struct {
@@ -118,6 +118,7 @@ static int open_wv_file(demux_wv_t *const this) {
WavpackContext *ctx = NULL;
char error[256]; /* Current version of wavpack (4.31) does not write more than this */
wvheader_t header;
+ uint32_t tmp;
/* Right now we don't support non-seekable streams */
if (! INPUT_IS_SEEKABLE(this->input) ) {
@@ -147,10 +148,14 @@ static int open_wv_file(demux_wv_t *const this) {
lprintf("number of samples: %u\n", this->samples);
this->samplerate = WavpackGetSampleRate(ctx);
lprintf("samplerate: %u Hz\n", this->samplerate);
- this->bits_per_sample = WavpackGetBitsPerSample(ctx);
- lprintf("bits_per_sample: %u\n", this->bits_per_sample);
- this->channels = WavpackGetNumChannels(ctx);
- lprintf("channels: %u\n", this->channels);
+
+ tmp = WavpackGetBitsPerSample(ctx); _x_assert(tmp <= 32);
+ lprintf("bits_per_sample: %u\n", tmp);
+ this->bits_per_sample = tmp;
+
+ tmp = WavpackGetNumChannels(ctx); _x_assert(tmp <= 8);
+ lprintf("channels: %u\n", tmp);
+ this->channels = tmp;
_x_stream_info_set(this->stream, XINE_STREAM_INFO_HAS_AUDIO, 1);
_x_stream_info_set(this->stream, XINE_STREAM_INFO_AUDIO_FOURCC,