From 5c3731ea37d69c0e6fdaaf423609f4d82516d685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 26 Dec 2006 15:06:52 +0000 Subject: [PATCH] gst/gstregistryxml.c: Make sure we don't pass non-UTF-8 strings to g_markup_escape(), since that can lead to random m... Original commit message from CVS: * gst/gstregistryxml.c: (gst_registry_save_escaped): Make sure we don't pass non-UTF-8 strings to g_markup_escape(), since that can lead to random memory corruptions and crashes (may or may not be related to #383244, #386711, and #386711). --- ChangeLog | 7 +++++++ gst/gstregistryxml.c | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 201517bd48..598b6ce51b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-12-26 Tim-Philipp Müller + + * gst/gstregistryxml.c: (gst_registry_save_escaped): + Make sure we don't pass non-UTF-8 strings to g_markup_escape(), + since that can lead to random memory corruptions and crashes + (may or may not be related to #383244, #386711, and #386711). + 2006-12-21 Stefan Kost * tests/check/.cvsignore: diff --git a/gst/gstregistryxml.c b/gst/gstregistryxml.c index eebbd8fc76..8f8e766d24 100644 --- a/gst/gstregistryxml.c +++ b/gst/gstregistryxml.c @@ -594,7 +594,14 @@ gst_registry_save_escaped (GstRegistry * registry, char *prefix, char *tag, gboolean ret = TRUE; if (value) { - gchar *v = g_markup_escape_text (value, strlen (value)); + gchar *v; + + if (g_utf8_validate (value, -1, NULL)) { + v = g_markup_escape_text (value, -1); + } else { + g_warning ("Invalid UTF-8 while saving registry tag '%s'", tag); + v = g_strdup ("[ERROR: invalid UTF-8]"); + } ret = gst_registry_save (registry, "%s<%s>%s\n", prefix, tag, v, tag); g_free (v);