Commit add8534f authored by Laurent Aimar's avatar Laurent Aimar

Prevent a potential integer overflow (mkv).

parent 059a5785
......@@ -458,7 +458,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;
......@@ -536,6 +536,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() );
......
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment