[gnome-packagekit] Check the language tags before trying to parse them. Fixes fd#22792



commit 89c3d43663aef0c6f32cd7ec68aee2692e23dc25
Author: Richard Hughes <richard hughsie com>
Date:   Thu Jul 16 09:12:33 2009 +0100

    Check the language tags before trying to parse them. Fixes fd#22792

 src/gpk-dbus-task.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index e90076f..3e30f64 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -2696,6 +2696,7 @@ gpk_dbus_task_install_fontconfig_resources (GpkDbusTask *task, gchar **fonts)
 	GError *error_local = NULL;
 	guint i;
 	guint len;
+	guint size;
 	gchar *text;
 	gchar *message;
 	const gchar *title;
@@ -2722,6 +2723,23 @@ gpk_dbus_task_install_fontconfig_resources (GpkDbusTask *task, gchar **fonts)
 		goto skip_checks;
 	}
 
+	/* check we got valid data */
+	for (i=0; i<len; i++) {
+		/* correct prefix */
+		if (!g_str_has_prefix (fonts[i], ":lang=")) {
+			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "not recognised prefix: '%s'", fonts[i]);
+			dbus_g_method_return_error (task->priv->context, error);
+			goto out;
+		}
+		/* no lang code */
+		size = strlen (fonts[i]);
+		if (size < 7 || size > 20) {
+			error = g_error_new (GPK_DBUS_ERROR, GPK_DBUS_ERROR_INTERNAL_ERROR, "lang tag malformed: '%s'", fonts[i]);
+			dbus_g_method_return_error (task->priv->context, error);
+			goto out;
+		}
+	}
+
 	string = g_string_new ("");
 
 	/* don't use a bullet for one item */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]