# HG changeset patch # User Mark Doliner # Date 1313656884 0 # Node ID d2eb28c12d44cb106f5981eb40a69632dd1f708e # Parent 70ff869a74d1834987da924b7c5c09a39f1ad08f Fix a crash when remote users have certain characters in their nicknames. (Discovered by Djego Ibanez) Fixes #14341 diff -r 70ff869a74d1 -r d2eb28c12d44 ChangeLog --- a/ChangeLog Thu Aug 18 08:38:23 2011 +0000 +++ b/ChangeLog Thu Aug 18 08:41:24 2011 +0000 @@ -35,6 +35,8 @@ ICQ account that is configured as an AIM account. (#14437) IRC: + * Fix a crash when remote users have certain characters in their + nicknames. (Discovered by Djego Ibanez) (#14341) * Fix the handling of formatting following mIRC ^O (#14436) * Fix crash when NAMES is empty. (James McLaughlin) (#14518) diff -r 70ff869a74d1 -r d2eb28c12d44 libpurple/protocols/irc/msgs.c --- a/libpurple/protocols/irc/msgs.c Thu Aug 18 08:38:23 2011 +0000 +++ b/libpurple/protocols/irc/msgs.c Thu Aug 18 08:41:24 2011 +0000 @@ -409,14 +409,21 @@ PurpleConvChat *chat; PurpleConvChatBuddy *cb; - char *userhost, *realname; + char *cur, *userhost, *realname; PurpleConvChatBuddyFlags flags; GList *keys = NULL, *values = NULL; - + + if (!args || !args[0] || !args[1] || !args[2] || !args[3] + || !args[4] || !args[5] || !args[6] || !args[7]) { + purple_debug(PURPLE_DEBUG_ERROR, "irc", + "Got a WHO response with not enough arguments\n"); + return; + } + conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); if (!conv) { - purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a WHO response for %s, which doesn't exist\n", args[1]); + purple_debug(PURPLE_DEBUG_ERROR, "irc","Got a WHO response for %s, which doesn't exist\n", args[1]); return; } @@ -429,7 +436,16 @@ chat = PURPLE_CONV_CHAT(conv); userhost = g_strdup_printf("%s@%s", args[2], args[3]); - realname = g_strdup(args[8]); + + /* The final argument is a :-argument, but annoyingly + * contains two "words", the hop count and real name. */ + for (cur = args[7]; *cur; cur++) { + if (*cur == ' ') { + cur++; + break; + } + } + realname = g_strdup(cur); keys = g_list_prepend(keys, "userhost"); values = g_list_prepend(values, userhost); diff -r 70ff869a74d1 -r d2eb28c12d44 libpurple/protocols/irc/parse.c --- a/libpurple/protocols/irc/parse.c Thu Aug 18 08:38:23 2011 +0000 +++ b/libpurple/protocols/irc/parse.c Thu Aug 18 08:41:24 2011 +0000 @@ -74,7 +74,7 @@ { "331", "nc:", irc_msg_topic }, /* No channel topic */ { "332", "nc:", irc_msg_topic }, /* Channel topic */ { "333", "*", irc_msg_ignore }, /* Topic setter stuff */ - { "352", "nvcvnvvv:", irc_msg_who },/* Channel WHO */ + { "352", "ncvvvnv:", irc_msg_who }, /* Channel WHO */ { "353", "nvc:", irc_msg_names }, /* Names list */ { "366", "nc:", irc_msg_names }, /* End of names */ { "367", "ncnnv", irc_msg_ban }, /* Ban list */