[vlc-devel] commit: ChunkFind: fix skipping very large chunks ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jun 28 13:04:09 CEST 2008


vlc | branch: 0.8.6-bugfix | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Jun 28 13:32:07 2008 +0300| [e173feddaaaf9d4138184547f899723f209895e2]

ChunkFind: fix skipping very large chunks

(cherry picked from commit c8ef76214a724af64c07fc20d88fcd4dc0459694)

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

 modules/demux/wav.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/modules/demux/wav.c b/modules/demux/wav.c
index ae70637..d0dbeff 100644
--- a/modules/demux/wav.c
+++ b/modules/demux/wav.c
@@ -31,6 +31,7 @@
 #include <vlc/aout.h>
 
 #include <codecs.h>
+#include <inttypes.h>
 
 /*****************************************************************************
  * Module descriptor
@@ -380,17 +381,17 @@ static int ChunkFind( demux_t *p_demux, char *fcc, unsigned int *pi_size )
 
     for( ;; )
     {
-        int i_size;
+        uint32_t i_size;
 
         if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
         {
-            msg_Err( p_demux, "cannot peek()" );
+            msg_Err( p_demux, "cannot peek" );
             return VLC_EGENERIC;
         }
 
         i_size = GetDWLE( p_peek + 4 );
 
-        msg_Dbg( p_demux, "chunk: fcc=`%4.4s` size=%d", p_peek, i_size );
+        msg_Dbg( p_demux, "chunk: fcc=`%4.4s` size=%"PRIu32, p_peek, i_size );
 
         if( !memcmp( p_peek, fcc, 4 ) )
         {
@@ -401,11 +402,11 @@ static int ChunkFind( demux_t *p_demux, char *fcc, unsigned int *pi_size )
             return VLC_SUCCESS;
         }
 
-        i_size = __EVEN( i_size ) + 8;
-        if( stream_Read( p_demux->s, NULL, i_size ) != i_size )
-        {
+        /* Skip chunk */
+        if( stream_Read( p_demux->s, NULL, 8 ) != 8
+         || stream_Read( p_demux->s, NULL, i_size ) != i_size
+         || ((i_size & 1) && stream_Read( p_demux->s, NULL, 1 ) != 1 ))
             return VLC_EGENERIC;
-        }
     }
 }
 




More information about the vlc-devel mailing list