From ba7569028c1fe20f4271560cb140c83da96242a5 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 12 Apr 2012 15:47:24 +0200 Subject: [PATCH] audioparsers: Check return value of GstBitReader/GstByteReader --- gst/audioparsers/gstaacparse.c | 6 ++++-- gst/audioparsers/gstflacparse.c | 3 ++- gst/audioparsers/gstwavpackparse.c | 22 +++++++++++++--------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c index 9123807..b082076 100644 --- a/gst/audioparsers/gstaacparse.c +++ b/gst/audioparsers/gstaacparse.c @@ -478,7 +478,8 @@ gst_aac_parse_read_loas_config (GstAacParse * aacparse, const guint8 * data, gst_bit_reader_init (&br, data, avail); /* skip sync word (11 bits) and size (13 bits) */ - gst_bit_reader_skip (&br, 11 + 13); + if (!gst_bit_reader_skip (&br, 11 + 13)) + return FALSE; /* First bit is "use last config" */ if (!gst_bit_reader_get_bits_uint8 (&br, &u8, 1)) @@ -547,7 +548,8 @@ gst_aac_parse_read_loas_config (GstAacParse * aacparse, const guint8 * data, sample_rate, channels, &bits)) return FALSE; asc_len -= bits; - gst_bit_reader_skip (&br, asc_len); + if (!gst_bit_reader_skip (&br, asc_len)) + return FALSE; } } } diff --git a/gst/audioparsers/gstflacparse.c b/gst/audioparsers/gstflacparse.c index 026e760..5ca2ca1 100644 --- a/gst/audioparsers/gstflacparse.c +++ b/gst/audioparsers/gstflacparse.c @@ -865,7 +865,8 @@ gst_flac_parse_handle_streaminfo (GstFlacParse * flacparse, GstBuffer * buffer) } /* Skip metadata block header */ - gst_bit_reader_skip (&reader, 32); + if (!gst_bit_reader_skip (&reader, 32)) + goto error; if (!gst_bit_reader_get_bits_uint16 (&reader, &flacparse->min_blocksize, 16)) goto error; diff --git a/gst/audioparsers/gstwavpackparse.c b/gst/audioparsers/gstwavpackparse.c index 211e04c..c3bcb68 100644 --- a/gst/audioparsers/gstwavpackparse.c +++ b/gst/audioparsers/gstwavpackparse.c @@ -385,6 +385,7 @@ gst_wavpack_parse_frame_header (GstWavpackParse * parse, GstBuffer * buf, GstByteReader br; WavpackHeader wph = { {0,}, 0, }; GstMapInfo map; + gboolean hdl = TRUE; g_return_val_if_fail (gst_buffer_get_size (buf) >= skip + sizeof (WavpackHeader), FALSE); @@ -396,15 +397,18 @@ gst_wavpack_parse_frame_header (GstWavpackParse * parse, GstBuffer * buf, gst_byte_reader_skip_unchecked (&br, skip + 4); /* read */ - gst_byte_reader_get_uint32_le (&br, &wph.ckSize); - gst_byte_reader_get_uint16_le (&br, &wph.version); - gst_byte_reader_get_uint8 (&br, &wph.track_no); - gst_byte_reader_get_uint8 (&br, &wph.index_no); - gst_byte_reader_get_uint32_le (&br, &wph.total_samples); - gst_byte_reader_get_uint32_le (&br, &wph.block_index); - gst_byte_reader_get_uint32_le (&br, &wph.block_samples); - gst_byte_reader_get_uint32_le (&br, &wph.flags); - gst_byte_reader_get_uint32_le (&br, &wph.crc); + hdl &= gst_byte_reader_get_uint32_le (&br, &wph.ckSize); + hdl &= gst_byte_reader_get_uint16_le (&br, &wph.version); + hdl &= gst_byte_reader_get_uint8 (&br, &wph.track_no); + hdl &= gst_byte_reader_get_uint8 (&br, &wph.index_no); + hdl &= gst_byte_reader_get_uint32_le (&br, &wph.total_samples); + hdl &= gst_byte_reader_get_uint32_le (&br, &wph.block_index); + hdl &= gst_byte_reader_get_uint32_le (&br, &wph.block_samples); + hdl &= gst_byte_reader_get_uint32_le (&br, &wph.flags); + hdl &= gst_byte_reader_get_uint32_le (&br, &wph.crc); + + if (!hdl) + GST_WARNING_OBJECT (parse, "Error reading header"); /* dump */ GST_LOG_OBJECT (parse, "size %d", wph.ckSize); -- 2.7.4