vlc | branch: master | Filip Roséen <[email protected]> | Mon Oct 31 15:07:45 2016 
+0100| [3a9943c78c71339168ef515b8d61134e5d40732c] | committer: Thomas Guillem

demux/mkv: fix 17575: ignore simple blocks preceeding timecode

As detailed in the matroska specification, the Timecode element within
a cluster is not only mandatory, it shall be the first element within
its parent (given that a SimpleBlock, and other entities, cannot be
interpreted correctly without it).

The previous implementation would assert inside libmatroska on
out-of-order blocks, causing us to crash. These changes are made so
that out-of-order elements are ignored instead of being a
point-of-failure.

An input where the added diagnostic is triggered is ill-formed.

 - https://www.matroska.org/technical/order/index.html

Signed-off-by: Steve Lhomme <[email protected]>
Signed-off-by: Thomas Guillem <[email protected]>

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

 modules/demux/mkv/matroska_segment.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/demux/mkv/matroska_segment.cpp 
b/modules/demux/mkv/matroska_segment.cpp
index 2eb74b0..ca5f34c 100644
--- a/modules/demux/mkv/matroska_segment.cpp
+++ b/modules/demux/mkv/matroska_segment.cpp
@@ -1147,9 +1147,11 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, 
KaxSimpleBlock * & pp_s
         int64_t            & i_duration;
         bool               & b_key_picture;
         bool               & b_discardable_picture;
+        bool                 b_cluster_timecode;
+
     } payload = {
         this, ep, &sys.demuxer, pp_block, pp_simpleblock,
-        *pi_duration, *pb_key_picture, *pb_discardable_picture
+        *pi_duration, *pb_key_picture, *pb_discardable_picture, true
     };
 
     MKV_SWITCH_CREATE( EbmlTypeDispatcher, BlockGetHandler_l1, BlockPayload )
@@ -1159,7 +1161,7 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, 
KaxSimpleBlock * & pp_s
         E_CASE( KaxCluster, kcluster )
         {
             vars.obj->cluster = &kcluster;
-
+            vars.b_cluster_timecode = false;
             vars.ep->Down ();
         }
         E_CASE( KaxCues, kcue )
@@ -1183,6 +1185,7 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, 
KaxSimpleBlock * & pp_s
             ktimecode.ReadData( vars.obj->es.I_O(), SCOPE_ALL_DATA );
             vars.obj->cluster->InitTimecode( static_cast<uint64>( ktimecode ), 
vars.obj->i_timescale );
             vars.obj->IndexAppendCluster( vars.obj->cluster );
+            vars.b_cluster_timecode = true;
         }
         E_CASE( KaxClusterSilentTracks, ksilent )
         {
@@ -1197,6 +1200,12 @@ int matroska_segment_c::BlockGet( KaxBlock * & pp_block, 
KaxSimpleBlock * & pp_s
         }
         E_CASE( KaxSimpleBlock, ksblock )
         {
+            if( vars.b_cluster_timecode == false )
+            {
+                msg_Warn( vars.p_demuxer, "ignoring SimpleBlock prior to 
mandatory Timecode" );
+                return;
+            }
+
             vars.simpleblock = &ksblock;
             vars.simpleblock->ReadData( vars.obj->es.I_O() );
             vars.simpleblock->SetParent( *vars.obj->cluster );

_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to