[vlc-commits] lpcm: validate block_nb_frames in DVD/LPCM cases

Filip Roséen git at videolan.org
Wed Dec 7 15:20:35 CET 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Dec  7 15:19:09 2016 +0100| [8447e3d87b65c36d57a2c55d4afb717bb1945321] | committer: Jean-Baptiste Kempf

lpcm: validate block_nb_frames in DVD/LPCM cases

Fix heap overflow due to invalid header data

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8447e3d87b65c36d57a2c55d4afb717bb1945321
---

 modules/codec/lpcm.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/modules/codec/lpcm.c b/modules/codec/lpcm.c
index 6b38abc..97b9a48 100644
--- a/modules/codec/lpcm.c
+++ b/modules/codec/lpcm.c
@@ -469,6 +469,20 @@ static block_t *DecodeFrame( decoder_t *p_dec, block_t **pp_block )
         p_block->p_buffer += p_sys->i_header_size + i_padding;
         p_block->i_buffer -= p_sys->i_header_size + i_padding;
 
+        const unsigned block_nb_frames = p_block->i_buffer / ( i_bits * 4 / 8 );
+        const unsigned aout_nb_frames = p_aout_buffer->i_nb_samples
+            / ( p_dec->fmt_out.audio.i_bitspersample / 8 );
+
+        if( block_nb_frames > aout_nb_frames )
+        {
+            msg_Warn( p_dec, "invalid block size" );
+
+            block_Release( p_block );
+            block_Release( p_aout_buffer );
+
+            return NULL;
+        }
+
         switch( p_sys->i_type )
         {
         case LPCM_WIDI:



More information about the vlc-commits mailing list