[at-spi2-atk] Check table description strings for valid UTF-8



commit 7540b8404de04eca32735fec3482b9b42d1e432f
Author: Mike Gorse <mgorse novell com>
Date:   Mon May 16 15:56:25 2011 -0500

    Check table description strings for valid UTF-8

 atk-adaptor/adaptors/table-adaptor.c |   19 +++++++++++++++----
 1 files 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)
     {



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