Commit b3b751cb authored by Edward Wang's avatar Edward Wang Committed by Jean-Baptiste Kempf

png: Check length before read

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 72628474
......@@ -91,12 +91,14 @@ static int OpenDecoder( vlc_object_t *p_this )
static void user_read( png_structp p_png, png_bytep data, png_size_t i_length )
{
block_t *p_block = (block_t *)png_get_io_ptr( p_png );
png_size_t i_read = __MIN( p_block->i_buffer, i_length );
if( i_length > p_block->i_buffer ) {
png_error( p_png, "not enough data" );
return;
}
memcpy( data, p_block->p_buffer, i_length );
p_block->p_buffer += i_length;
p_block->i_buffer -= i_length;
if( i_length != i_read ) png_error( p_png, "not enough data" );
}
static void user_error( png_structp p_png, png_const_charp error_msg )
......
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