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.
This commit is contained in:
Tim-Philipp Müller 2005-10-09 17:59:08 +00:00
parent d8efd5cc51
commit 2b41c044a2
3 changed files with 30 additions and 2 deletions

View file

@ -1,3 +1,11 @@
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),

View file

@ -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:

View file

@ -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: