[vlc-commits] commit: Prevent a potential integer overflow (mkv). (Laurent Aimar )

git at videolan.org git at videolan.org
Thu Apr 15 18:54:47 CEST 2010


vlc/vlc-1.0 | branch: master | Laurent Aimar <fenrir at videolan.org> | Sun Feb 28 12:48:10 2010 +0100| [12d8ff82aa494111f7d5ddbb244e49b29f2faf79] | committer: Rémi Denis-Courmont 

Prevent a potential integer overflow (mkv).

(cherry picked from commit add8534f31b7c7ff20503169437d7d47ec3ac156)
Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

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

 modules/demux/mkv/mkv.cpp |    4 +++-
 modules/demux/mkv/mkv.hpp |    1 +
 2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/modules/demux/mkv/mkv.cpp b/modules/demux/mkv/mkv.cpp
index f2c2a75..c405fa1 100644
--- a/modules/demux/mkv/mkv.cpp
+++ b/modules/demux/mkv/mkv.cpp
@@ -456,7 +456,7 @@ static void Seek( demux_t *p_demux, mtime_t i_date, double f_percent, chapter_it
 }
 
 /* Utility function for BlockDecode */
-static block_t *MemToBlock( demux_t *p_demux, uint8_t *p_mem, int i_mem, size_t offset)
+static block_t *MemToBlock( demux_t *p_demux, uint8_t *p_mem, size_t i_mem, size_t offset)
 {
     block_t *p_block;
     if( !(p_block = block_New( p_demux, i_mem + offset ) ) ) return NULL;
@@ -534,6 +534,8 @@ static void BlockDecode( demux_t *p_demux, KaxBlock *block, KaxSimpleBlock *simp
         {
             data = &block->GetBuffer(i);
         }
+        if( !data->Buffer() || data->Size() > SIZE_MAX )
+            break;
 
         if( tk->i_compression_type == MATROSKA_COMPRESSION_HEADER && tk->p_compression_data != NULL )
             p_block = MemToBlock( p_demux, data->Buffer(), data->Size(), tk->p_compression_data->GetSize() );
diff --git a/modules/demux/mkv/mkv.hpp b/modules/demux/mkv/mkv.hpp
index c01e5ff..0ea8ccb 100644
--- a/modules/demux/mkv/mkv.hpp
+++ b/modules/demux/mkv/mkv.hpp
@@ -34,6 +34,7 @@
  * early enough. */
 #define __STDC_FORMAT_MACROS 1
 #define __STDC_CONSTANT_MACROS 1
+#define __STDC_LIMIT_MACROS 1
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"



More information about the vlc-commits mailing list