From 322baf19c80857f1f2b016ec6bf043d09c67d154 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 24 Jul 2003 08:49:42 +0000 Subject: Add buffer length checks to every typefinding function Original commit message from CVS: Add buffer length checks to every typefinding function --- ext/dv/gstdvdec.c | 7 ++++++- ext/flac/gstflac.c | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'ext') diff --git a/ext/dv/gstdvdec.c b/ext/dv/gstdvdec.c index d7500cc6..e28f8362 100644 --- a/ext/dv/gstdvdec.c +++ b/ext/dv/gstdvdec.c @@ -161,9 +161,14 @@ GST_PAD_TEMPLATE_FACTORY ( audio_src_temp, static GstCaps* dv_type_find (GstBuffer *buf, gpointer private) { - guint32 head = GUINT32_FROM_BE(*((guint32 *)GST_BUFFER_DATA(buf))); + guint32 head; GstCaps *new = NULL; + if (GST_BUFFER_SIZE (buf) < 5) + return NULL; + + head = GUINT32_FROM_BE(*((guint32 *)GST_BUFFER_DATA(buf))); + /* check for DIF and DV flag */ if ((head & 0xffffff00) == 0x1f070000 && !(GST_BUFFER_DATA(buf)[4] & 0x01)) { gchar *format; diff --git a/ext/flac/gstflac.c b/ext/flac/gstflac.c index af10d794..b8dd73e8 100644 --- a/ext/flac/gstflac.c +++ b/ext/flac/gstflac.c @@ -71,8 +71,12 @@ static GstTypeDefinition flacdefinition = { static GstCaps* flac_type_find (GstBuffer *buf, gpointer private) { - guint32 head = GUINT32_FROM_BE (*((guint32 *)GST_BUFFER_DATA (buf))); + guint32 head; + + if (GST_BUFFER_SIZE (buf) < 4) + return NULL; + head = GUINT32_FROM_BE (*((guint32 *)GST_BUFFER_DATA (buf))); if (head != 0x664C6143) return NULL; -- cgit