Commit ad244628 authored by Denis Charmet's avatar Denis Charmet Committed by Jean-Baptiste Kempf

Handle mkv file with random data appended

EbmlElement doesn't detect EOF so we don't try to look for more than the file size.
Close #5287
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 69a96ade
......@@ -24,6 +24,7 @@
*****************************************************************************/
#include "Ebml_parser.hpp"
#include "stream_io_callback.hpp"
/*****************************************************************************
* Ebml Stream parser
......@@ -77,7 +78,7 @@ EbmlElement* EbmlParser::UnGet( uint64 i_block_pos, uint64 i_cluster_pos )
}
m_got = NULL;
mb_keep = false;
if ( m_el[1]->GetElementPosition() == i_cluster_pos )
if ( m_el[1] && m_el[1]->GetElementPosition() == i_cluster_pos )
{
m_es->I_O().setFilePointer( i_block_pos, seek_beginning );
return (EbmlMaster*) m_el[1];
......@@ -161,8 +162,9 @@ EbmlElement *EbmlParser::Get( void )
}
mb_keep = false;
}
m_el[mi_level] = m_es->FindNextElement( EBML_CONTEXT(m_el[mi_level - 1]), i_ulev, 0xFFFFFFFFL, mb_dummy != 0, 1 );
vlc_stream_io_callback & io_stream = (vlc_stream_io_callback &) m_es->I_O();
uint64 i_size = io_stream.toRead();
m_el[mi_level] = m_es->FindNextElement( EBML_CONTEXT(m_el[mi_level - 1]), i_ulev, i_size, mb_dummy != 0, 1 );
// mi_remain_size[mi_level] = m_el[mi_level]->GetSize();
if( i_ulev > 0 )
{
......
......@@ -87,3 +87,18 @@ size_t vlc_stream_io_callback::write(const void *, size_t )
return 0;
}
uint64 vlc_stream_io_callback::toRead( void )
{
uint64_t i_size;
if( s == NULL)
return 0;
stream_Control( s, STREAM_GET_SIZE, &i_size );
if( i_size == 0 )
return 0xFFFFFFFFL;
return (uint64) i_size - stream_Tell( s );
}
......@@ -47,5 +47,6 @@ class vlc_stream_io_callback: public IOCallback
virtual size_t write ( const void *p_buffer, size_t i_size);
virtual uint64 getFilePointer ( void );
virtual void close ( void ) { return; }
uint64 toRead ( void );
};
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