# HG changeset patch # User Mark Doliner # Date 1255682211 0 # Node ID 63881771e1bf17a13d31fc1ca99808016617d89c # Parent 64fbf431d9520171d46b0d7671b5fde57bb77c79 Fix a remote-crash bug in ICQ (and probably AIM). It happens when the SIM IM client tries to send us contacts. Fixes #10481 diff -r 64fbf431d952 -r 63881771e1bf libpurple/protocols/oscar/oscar.c --- a/libpurple/protocols/oscar/oscar.c Fri Oct 16 04:42:39 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Fri Oct 16 08:36:51 2009 +0000 @@ -2874,25 +2874,46 @@ gchar **text; text = g_strsplit(args->msg, "\376", 0); if (text) { - num = 0; - for (i=0; iuin, text[i*2+2], text[i*2+1]); - data->gc = gc; - data->name = g_strdup(text[i*2+1]); - data->nick = g_strdup(text[i*2+2]); - - purple_request_action(gc, NULL, message, - _("Do you want to add this buddy " - "to your buddy list?"), - PURPLE_DEFAULT_ACTION_NONE, - purple_connection_get_account(gc), data->name, NULL, - data, 2, - _("_Add"), G_CALLBACK(purple_icq_buddyadd), - _("_Decline"), G_CALLBACK(oscar_free_name_data)); - g_free(message); + /* Read the number of contacts that we were sent */ + errno = 0; + num = strtoul(text[0], NULL, 10); + + if (num > 0 && errno == 0) { + for (i=0; imsg, NULL); + purple_debug_error("oscar", "Unknown syntax parsing " + "ICQ buddies. args->msg=%s\n", tmp); + g_free(tmp); + break; + } + + message = g_strdup_printf(_("ICQ user %u has sent you a buddy: %s (%s)"), args->uin, text[i*2+2], text[i*2+1]); + + data = g_new(struct name_data, 1); + data->gc = gc; + data->name = g_strdup(text[i*2+1]); + data->nick = g_strdup(text[i*2+2]); + + purple_request_action(gc, NULL, message, + _("Do you want to add this buddy " + "to your buddy list?"), + PURPLE_DEFAULT_ACTION_NONE, + purple_connection_get_account(gc), data->name, NULL, + data, 2, + _("_Add"), G_CALLBACK(purple_icq_buddyadd), + _("_Decline"), G_CALLBACK(oscar_free_name_data)); + g_free(message); + } + } else { + gchar *tmp = g_strescape(args->msg, NULL); + purple_debug_error("oscar", "Unknown syntax parsing " + "ICQ buddies. args->msg=%s\n", tmp); + g_free(tmp); } g_strfreev(text); }