From: Vivia Nikolaidou Date: Fri, 10 Feb 2023 13:43:45 +0000 (+0200) Subject: qtdemux: Handle moov atom length=0 case by reading until the end X-Git-Tag: 1.22.7~496 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=625f9aab09f70887491da14d1cc6a61cc55a8ec0;p=platform%2Fupstream%2Fgstreamer.git qtdemux: Handle moov atom length=0 case by reading until the end Previously it would fail to demux the file by trying to read G_MAXUINT64 bytes. Part-of: --- diff --git a/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c b/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c index b20c255..027529a 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c +++ b/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c @@ -4642,6 +4642,36 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux) goto beach; } + if (length == G_MAXUINT64) { + /* Read until the end */ + gint64 duration; + if (!gst_pad_peer_query_duration (qtdemux->sinkpad, GST_FORMAT_BYTES, + &duration)) { + GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX, + (_("Cannot query file size")), + ("Duration query on sink pad failed")); + ret = GST_FLOW_ERROR; + goto beach; + } + if (G_UNLIKELY (cur_offset > duration)) { + GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX, + (_("Cannot query file size")), + ("Duration %" G_GINT64_FORMAT " < current offset %" + G_GUINT64_FORMAT, duration, cur_offset)); + ret = GST_FLOW_ERROR; + goto beach; + } + length = duration - cur_offset; + if (length > QTDEMUX_MAX_ATOM_SIZE) { + GST_ELEMENT_ERROR (qtdemux, STREAM, DEMUX, + (_("Cannot demux file")), + ("Moov atom size %" G_GINT64_FORMAT " > maximum %d", length, + QTDEMUX_MAX_ATOM_SIZE)); + ret = GST_FLOW_ERROR; + goto beach; + } + } + ret = gst_pad_pull_range (qtdemux->sinkpad, cur_offset, length, &moov); if (ret != GST_FLOW_OK) goto beach;