From 7540b8404de04eca32735fec3482b9b42d1e432f Mon Sep 17 00:00:00 2001 From: Mike Gorse Date: Mon, 16 May 2011 15:56:25 -0500 Subject: [PATCH] Check table description strings for valid UTF-8 --- atk-adaptor/adaptors/table-adaptor.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/atk-adaptor/adaptors/table-adaptor.c b/atk-adaptor/adaptors/table-adaptor.c index 59d45e8..f296816 100644 --- a/atk-adaptor/adaptors/table-adaptor.c +++ b/atk-adaptor/adaptors/table-adaptor.c @@ -199,6 +199,19 @@ impl_GetColumnAtIndex (DBusConnection * bus, DBusMessage * message, return reply; } +static gchar * +validate_unallocated_string (gchar *str) +{ + if (!str) + return ""; + if (!g_utf8_validate (str, -1, NULL)) + { + g_warning ("atk-bridge: received bad UTF-8 string from a table function"); + return ""; + } + return str; +} + static DBusMessage * impl_GetRowDescription (DBusConnection * bus, DBusMessage * message, void *user_data) @@ -218,8 +231,7 @@ impl_GetRowDescription (DBusConnection * bus, DBusMessage * message, return droute_invalid_arguments_error (message); } description = atk_table_get_row_description (table, row); - if (!description) - description = ""; + description = validate_unallocated_string (description); reply = dbus_message_new_method_return (message); if (reply) { @@ -248,8 +260,7 @@ impl_GetColumnDescription (DBusConnection * bus, DBusMessage * message, return droute_invalid_arguments_error (message); } description = atk_table_get_column_description (table, column); - if (!description) - description = ""; + description = validate_unallocated_string (description); reply = dbus_message_new_method_return (message); if (reply) { -- 2.7.4