Commit 2b41c044 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠
Browse files

gst/base/gsttypefindhelper.c: Fix evil typefind crasher: getrange() might...

gst/base/gsttypefindhelper.c: Fix evil typefind crasher: getrange() might return a short buffer at the end of a file,...

Original commit message from CVS:
* gst/base/gsttypefindhelper.c: (helper_find_peek):
Fix evil typefind crasher: getrange() might return a short
buffer at the end of a file, but gst_type_find_peek() must
either return the full data as requested or NULL, but
never a short buffer.
parent d8efd5cc
2005-10-09 Tim-Philipp Müller <tim at centricular dot net>
* gst/base/gsttypefindhelper.c: (helper_find_peek):
Fix evil typefind crasher: getrange() might return a short
buffer at the end of a file, but gst_type_find_peek() must
either return the full data as requested or NULL, but
never a short buffer.
2005-10-09 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/gstmessage.c: (gst_message_new_state_changed),
......
......@@ -75,8 +75,18 @@ helper_find_peek (gpointer data, gint64 offset, guint size)
if (ret != GST_FLOW_OK)
goto error;
find->buffers = g_list_prepend (find->buffers, buffer);
/* getrange might silently return shortened buffers at the end of a file,
* we must, however, always return either the full requested data or NULL */
if (GST_BUFFER_OFFSET (buffer) != offset || GST_BUFFER_SIZE (buffer) < size) {
GST_DEBUG ("droping short buffer: %" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT
" instead of %" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT,
GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET (buffer) +
GST_BUFFER_SIZE (buffer), offset, offset + size);
gst_buffer_unref (buffer);
return NULL;
}
find->buffers = g_list_prepend (find->buffers, buffer);
return GST_BUFFER_DATA (buffer);
error:
......
......@@ -75,8 +75,18 @@ helper_find_peek (gpointer data, gint64 offset, guint size)
if (ret != GST_FLOW_OK)
goto error;
find->buffers = g_list_prepend (find->buffers, buffer);
/* getrange might silently return shortened buffers at the end of a file,
* we must, however, always return either the full requested data or NULL */
if (GST_BUFFER_OFFSET (buffer) != offset || GST_BUFFER_SIZE (buffer) < size) {
GST_DEBUG ("droping short buffer: %" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT
" instead of %" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT,
GST_BUFFER_OFFSET (buffer), GST_BUFFER_OFFSET (buffer) +
GST_BUFFER_SIZE (buffer), offset, offset + size);
gst_buffer_unref (buffer);
return NULL;
}
find->buffers = g_list_prepend (find->buffers, buffer);
return GST_BUFFER_DATA (buffer);
error:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment