[vlc-devel] [PATCH] demux/mkv: fix 17575: ignore simple blocks preceeding timecode

Steve Lhomme robux4 at gmail.com
Wed Nov 2 08:51:13 CET 2016


LGTM

On Mon, Oct 31, 2016 at 3:07 PM, Filip Roséen <filip at atch.se> wrote:
> 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
> ---
>  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 266477f..b2323d7 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 );
> --
> 2.10.1
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list