GST_DEBUG ("atom type %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS (fourcc));
if (length == 0) {
- length = G_MAXUINT32;
+ length = G_MAXUINT64;
} else if (length == 1 && size >= 16) {
/* this means we have an extended size, which is the 64 bit value of
* the next 8 bytes */
}
}
+static guint64
+add_offset (guint64 offset, guint64 advance)
+{
+ /* Avoid 64-bit overflow by clamping */
+ if (offset > G_MAXUINT64 - advance)
+ return G_MAXUINT64;
+ return offset + advance;
+}
+
static GstFlowReturn
gst_qtdemux_loop_state_header (GstQTDemux * qtdemux)
{
GST_LOG_OBJECT (qtdemux,
"skipping atom '%" GST_FOURCC_FORMAT "' at %" G_GUINT64_FORMAT,
GST_FOURCC_ARGS (fourcc), cur_offset);
- qtdemux->offset += length;
+ qtdemux->offset = add_offset (qtdemux->offset, length);
break;
}
case FOURCC_moov:
if (qtdemux->got_moov) {
GST_DEBUG_OBJECT (qtdemux, "Skipping moov atom as we have one already");
- qtdemux->offset += length;
+ qtdemux->offset = add_offset (qtdemux->offset, length);
goto beach;
}