gst/qtdemux/qtdemux.c: Some 'broken' files out there have atom lengths of zero.....
authorEdward Hervey <bilboed@bilboed.com>
Wed, 17 Sep 2008 14:50:42 +0000 (14:50 +0000)
committerEdward Hervey <bilboed@bilboed.com>
Wed, 17 Sep 2008 14:50:42 +0000 (14:50 +0000)
Original commit message from CVS:
* gst/qtdemux/qtdemux.c: (gst_qtdemux_loop_state_header),
(gst_qtdemux_chain):
Some 'broken' files out there have atom lengths of zero...
which basically results in qtdemux consuming that atom again and again
until the *end of night* !
Detect that and emits an adequate element error message.

ChangeLog
gst/qtdemux/qtdemux.c

index 6882ca6..7e2a854 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-09-17  Edward Hervey  <edward.hervey@collabora.co.uk>
+
+       * gst/qtdemux/qtdemux.c: (gst_qtdemux_loop_state_header),
+       (gst_qtdemux_chain):
+       Some 'broken' files out there have atom lengths of zero...
+       which basically results in qtdemux consuming that atom again and again
+       until the *end of night* !
+       Detect that and emits an adequate element error message.
+
 2008-09-17  Jan Schmidt  <jan.schmidt@sun.com>
 
        * gst/interleave/Makefile.am:
index 63ba038..f0b89d5 100644 (file)
@@ -1089,6 +1089,15 @@ gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
   extract_initial_length_and_fourcc (GST_BUFFER_DATA (buf), &length, &fourcc);
   gst_buffer_unref (buf);
 
+  if (length == 0) {
+    GST_ELEMENT_ERROR (qtdemux, STREAM, DECODE,
+        (_("This file is invalid and cannot be played.")),
+        ("Header atom '%" GST_FOURCC_FORMAT "' has empty length",
+            GST_FOURCC_ARGS (fourcc)));
+    ret = GST_FLOW_ERROR;
+    goto beach;
+  }
+
   switch (fourcc) {
     case FOURCC_mdat:
     case FOURCC_free:
@@ -2092,6 +2101,14 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
         GST_DEBUG_OBJECT (demux,
             "Peeking found [%" GST_FOURCC_FORMAT "] size: %u",
             GST_FOURCC_ARGS (fourcc), (guint) size);
+        if (size == 0) {
+          GST_ELEMENT_ERROR (demux, STREAM, DECODE,
+              (_("This file is invalid and cannot be played.")),
+              ("initial atom '%" GST_FOURCC_FORMAT "' has empty length",
+                  GST_FOURCC_ARGS (fourcc)));
+          ret = GST_FLOW_ERROR;
+          break;
+        }
         if (fourcc == FOURCC_mdat) {
           if (demux->n_streams > 0) {
             demux->state = QTDEMUX_STATE_MOVIE;