summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2006-03-14 15:28:00 +0000
committerTim-Philipp Müller <tim@centricular.net>2006-03-14 15:28:00 +0000
commit6bad19a5886d0cd50f192a83f4d49e6bb6ef6a64 (patch)
tree472dbc9c33c4709b573ea51e627545be0859cde6
parent59bc72774d400dc1eace67dba5cd7601ad0f3e78 (diff)
gst/avi/gstavidemux.c: Catch short reads, like they might happen with truncated files (see #305279); remove unnecessa...
Original commit message from CVS: * gst/avi/gstavidemux.c: (gst_avi_demux_process_next_entry): Catch short reads, like they might happen with truncated files (see #305279); remove unnecessary indentation.
-rw-r--r--ChangeLog6
-rw-r--r--gst/avi/gstavidemux.c52
2 files changed, 36 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f704143..5c206ee6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2006-03-14 Tim-Philipp Müller <tim at centricular dot net>
+ * gst/avi/gstavidemux.c: (gst_avi_demux_process_next_entry):
+ Catch short reads, like they might happen with truncated
+ files (see #305279); remove unnecessary indentation.
+
+2006-03-14 Tim-Philipp Müller <tim at centricular dot net>
+
* gst/avi/gstavidemux.c: (gst_avi_demux_invert):
Fix DIB image inversion for pictures with a
depth != 8 (#305279).
diff --git a/gst/avi/gstavidemux.c b/gst/avi/gstavidemux.c
index 7bc478a4..77278fd0 100644
--- a/gst/avi/gstavidemux.c
+++ b/gst/avi/gstavidemux.c
@@ -2457,30 +2457,38 @@ gst_avi_demux_process_next_entry (GstAviDemux * avi)
}
if ((res = gst_pad_pull_range (avi->sinkpad, entry->offset +
- avi->index_offset, entry->size, &buf)) != GST_FLOW_OK)
+ avi->index_offset, entry->size, &buf)) != GST_FLOW_OK) {
return res;
- else {
- if (stream->strh->fcc_handler == GST_MAKE_FOURCC ('D', 'I', 'B', ' ')) {
- buf = gst_avi_demux_invert (stream, buf);
- }
- if (!(entry->flags & GST_RIFF_IF_KEYFRAME))
- GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
- GST_BUFFER_TIMESTAMP (buf) = entry->ts;
- GST_BUFFER_DURATION (buf) = entry->dur;
- gst_buffer_set_caps (buf, GST_PAD_CAPS (stream->pad));
- GST_DEBUG_OBJECT (avi, "Processing buffer of size %d and time %"
- GST_TIME_FORMAT " on pad %s",
- GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
- GST_PAD_NAME (stream->pad));
- res = gst_pad_push (stream->pad, buf);
- stream->last_flow = res;
- if (res != GST_FLOW_OK && res != GST_FLOW_NOT_LINKED) {
- GST_DEBUG_OBJECT (avi, "Flow on pad %s: %s",
- GST_PAD_NAME (stream->pad), gst_flow_get_name (res));
- return res;
- }
- processed = TRUE;
}
+
+ if (GST_BUFFER_SIZE (buf) < entry->size) {
+ GST_WARNING_OBJECT (avi, "Short read at offset %" G_GUINT64_FORMAT
+ ", only got %d/%d bytes (truncated file?)", entry->offset +
+ avi->index_offset, GST_BUFFER_SIZE (buf), entry->size);
+ goto eos;
+ }
+
+ if (stream->strh->fcc_handler == GST_MAKE_FOURCC ('D', 'I', 'B', ' ')) {
+ buf = gst_avi_demux_invert (stream, buf);
+ }
+ if (!(entry->flags & GST_RIFF_IF_KEYFRAME))
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT);
+ GST_BUFFER_TIMESTAMP (buf) = entry->ts;
+ GST_BUFFER_DURATION (buf) = entry->dur;
+ gst_buffer_set_caps (buf, GST_PAD_CAPS (stream->pad));
+ GST_DEBUG_OBJECT (avi, "Processing buffer of size %d and time %"
+ GST_TIME_FORMAT " on pad %s",
+ GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
+ GST_PAD_NAME (stream->pad));
+ res = gst_pad_push (stream->pad, buf);
+ stream->last_flow = res;
+ if (res != GST_FLOW_OK && res != GST_FLOW_NOT_LINKED) {
+ GST_DEBUG_OBJECT (avi, "Flow on pad %s: %s",
+ GST_PAD_NAME (stream->pad), gst_flow_get_name (res));
+ return res;
+ }
+ processed = TRUE;
+
next:
stream->current_frame = entry->frames_before + 1;
stream->current_byte = entry->bytes_before + entry->size;