[vlc-devel] commit: H264 packetizer : NEVER TRUST INPUT !! ( Rafaël Carré )

git version control git at videolan.org
Mon Mar 31 12:09:22 CEST 2008


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Fri Mar 28 16:51:16 2008 +0100| [ab4e8a39d0b2d9c2998d7ab248b83463fd67f2a1]

H264 packetizer : NEVER TRUST INPUT !!

Do not allocate ridiculous amount of datas.

Signed-off-by: Jean-Paul Saman <jpsaman at videolan.org>

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

 modules/packetizer/h264.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/packetizer/h264.c b/modules/packetizer/h264.c
index 04336a7..dac5ece 100644
--- a/modules/packetizer/h264.c
+++ b/modules/packetizer/h264.c
@@ -447,10 +447,14 @@ static block_t *PacketizeAVC1( decoder_t *p_dec, block_t **pp_block )
             i_size = (i_size << 8) | (*p++);
         }
 
-        if( i_size > 0 )
+        if( i_size > 0 && i_size < p_block->i_buffer )
         {
             block_t *p_part = nal_get_annexeb( p_dec, p, i_size );
-
+            if( !p_part )
+            {
+                block_Release( p_block );
+                return NULL;
+            }
             p_part->i_dts = p_block->i_dts;
             p_part->i_pts = p_block->i_pts;
 
@@ -472,6 +476,7 @@ static block_t *nal_get_annexeb( decoder_t *p_dec, uint8_t *p, int i_size )
     block_t *p_nal;
 
     p_nal = block_New( p_dec, 4 + i_size );
+    if( !p_nal ) return NULL;
 
     /* Add start code */
     p_nal->p_buffer[0] = 0x00;




More information about the vlc-devel mailing list