From 8213fc2edf8376aaf59978c7b7089eb6085eaa16 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Wed, 11 Apr 2018 08:42:54 +0200 Subject: [PATCH] qtdemux: Handle bogus caption samples Corrupted files could potentially have multiple cdat/cdt2 atoms in a sample entry, which is unclear how to handle. Ignore repeated ones. CID #1434162 CID #1434159 --- gst/isomp4/qtdemux.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index f732e92b32..44de3b79f4 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -5439,14 +5439,23 @@ extract_cc_from_data (QtDemuxStream * stream, const guint8 * data, gsize size, guint32 new_atom_length = QT_UINT32 (data + atom_length); if (size <= atom_length + new_atom_length) { fourcc = QT_FOURCC (data + atom_length + 4); - if (fourcc == FOURCC_cdat) - cdat = - convert_to_ccdata (data + atom_length + 8, new_atom_length - 8, - 1, &cdat_size); - else - cdt2 = - convert_to_ccdata (data + atom_length + 8, new_atom_length - 8, - 2, &cdt2_size); + if (fourcc == FOURCC_cdat) { + if (cdat == NULL) + cdat = + convert_to_ccdata (data + atom_length + 8, + new_atom_length - 8, 1, &cdat_size); + else + GST_WARNING_OBJECT (stream->pad, + "Got multiple [cdat] atoms in a c608 sample. This is unsupported for now. Please file a bug"); + } else { + if (cdt2 == NULL) + cdt2 = + convert_to_ccdata (data + atom_length + 8, + new_atom_length - 8, 2, &cdt2_size); + else + GST_WARNING_OBJECT (stream->pad, + "Got multiple [cdt2] atoms in a c608 sample. This is unsupported for now. Please file a bug"); + } } } *cclen = cdat_size + cdt2_size;