# HG changeset patch # User Ethan Blanton # Date 1163090106 0 # Node ID 06ae7ffc47e317fa36cdce3657c195893ba789a3 # Parent 4b2ac755d56598516b9c7de53da1d3be12982bf3 [gaim-migrate @ 17711] This should prevent D-BUS from having to deal with any non-UTF-8 strings emitted by Gaim signals, which should therefore prevent its early exit. Strings will be salvaged via gaim_utf8_salvage before emission, and an error will be logged. IRC (and any other protocols spitting out invalid UTF-8 to signals) should yet be fixed to emit some sort of binary blob, rather than a UTF-8 string, but this will make D-BUS robust to any future transgressions. This is completely untested. committer: Tailor Script diff -r 4b2ac755d565 -r 06ae7ffc47e3 libgaim/dbus-server.c --- a/libgaim/dbus-server.c Thu Nov 09 05:45:55 2006 +0000 +++ b/libgaim/dbus-server.c Thu Nov 09 16:35:06 2006 +0000 @@ -38,6 +38,7 @@ #include "core.h" #include "internal.h" #include "savedstatuses.h" +#include "util.h" #include "value.h" #include "xmlnode.h" @@ -667,6 +668,7 @@ guint xuint; gboolean xboolean; gpointer ptr = NULL; + gboolean allocated = FALSE; if (gaim_value_is_outgoing(gaim_values[i])) { @@ -690,7 +692,14 @@ break; case GAIM_TYPE_STRING: str = null_to_empty(my_arg(char*)); + if (!g_utf8_validate(str, -1, NULL)) { + gaim_debug_error("dbus", "Invalid UTF-8 string passed to signal, emitting salvaged string!\n"); + str = gaim_utf8_salvage(str); + allocated = TRUE; + } dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str); + if (allocated) + g_free(str); break; case GAIM_TYPE_SUBTYPE: /* registered pointers only! */ case GAIM_TYPE_POINTER: