From b57078cd603ad7aa0fd2f48762c124acbd8f863a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 9 Mar 2006 12:56:35 +0000 Subject: [PATCH] gst/subparse/gstsubparse.c: Fix invalid memory access: make sure string passed to regexec() is NUL-termianted. Original commit message from CVS: * gst/subparse/gstsubparse.c: (gst_subparse_type_find): Fix invalid memory access: make sure string passed to regexec() is NUL-termianted. --- ChangeLog | 6 ++++++ gst/subparse/gstsubparse.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9f19e0333f..81e21062d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-03-09 Tim-Philipp Müller + + * gst/subparse/gstsubparse.c: (gst_subparse_type_find): + Fix invalid memory access: make sure string passed to + regexec() is NUL-termianted. + 2006-03-09 Tim-Philipp Müller * gst/typefind/gsttypefindfunctions.c: (mp3_type_find_at_offset), diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index 0a324bea5b..df66006f00 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -867,10 +867,16 @@ gst_subparse_type_find (GstTypeFind * tf, gpointer private) { const guint8 *data; GstSubParseFormat format; + gchar *str; if (!(data = gst_type_find_peek (tf, 0, 36))) return; - format = gst_sub_parse_data_format_autodetect ((gchar *) data); + + /* make sure string passed to _autodetect() is NUL-terminated */ + str = g_strndup ((gchar *) data, 35); + format = gst_sub_parse_data_format_autodetect (str); + g_free (str); + switch (format) { case GST_SUB_PARSE_FORMAT_MDVDSUB: GST_DEBUG ("MicroDVD format detected");