Fix a crash when remote users have certain characters in their
authorMark Doliner <markdoliner@pidgin.im>
Thu, 18 Aug 2011 08:41:24 +0000
changeset619f32df41f1 pushlog
parent 4377067bda01
child 2379d8500566
Fix a crash when remote users have certain characters in their
nicknames. (Discovered by Djego Ibanez)
Fixes #14341
ChangeLog
libpurple/protocols/irc/msgs.c
libpurple/protocols/irc/parse.c
     1.1 --- a/ChangeLog
     1.2 +++ b/ChangeLog
     1.3 @@ -35,6 +35,8 @@
     1.4  	  ICQ account that is configured as an AIM account. (#14437)
     1.5  
     1.6  	IRC:
     1.7 +	* Fix a crash when remote users have certain characters in their
     1.8 +	  nicknames. (Discovered by Djego Ibanez) (#14341)
     1.9  	* Fix the handling of formatting following mIRC ^O (#14436)
    1.10  	* Fix crash when NAMES is empty. (James McLaughlin) (#14518)
    1.11  
     2.1 --- a/libpurple/protocols/irc/msgs.c
     2.2 +++ b/libpurple/protocols/irc/msgs.c
     2.3 @@ -409,14 +409,21 @@
     2.4  		PurpleConvChat *chat;
     2.5  		PurpleConvChatBuddy *cb;
     2.6  		
     2.7 -		char *userhost, *realname;
     2.8 +		char *cur, *userhost, *realname;
     2.9  		
    2.10  		PurpleConvChatBuddyFlags flags;
    2.11  		GList *keys = NULL, *values = NULL;
    2.12 -		
    2.13 +
    2.14 +		if (!args || !args[0] || !args[1] || !args[2] || !args[3]
    2.15 +		    || !args[4] || !args[5] || !args[6] || !args[7]) {
    2.16 +			purple_debug(PURPLE_DEBUG_ERROR, "irc",
    2.17 +				     "Got a WHO response with not enough arguments\n");
    2.18 +			return;
    2.19 +		}
    2.20 +
    2.21  		conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account);
    2.22  		if (!conv) {
    2.23 -			purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a WHO response for %s, which doesn't exist\n", args[1]);
    2.24 +			purple_debug(PURPLE_DEBUG_ERROR, "irc","Got a WHO response for %s, which doesn't exist\n", args[1]);
    2.25  			return;
    2.26  		}
    2.27  
    2.28 @@ -429,7 +436,16 @@
    2.29  		chat = PURPLE_CONV_CHAT(conv);
    2.30  		
    2.31  		userhost = g_strdup_printf("%s@%s", args[2], args[3]);
    2.32 -		realname = g_strdup(args[8]);
    2.33 +
    2.34 +		/* The final argument is a :-argument, but annoyingly
    2.35 +		 * contains two "words", the hop count and real name. */
    2.36 +		for (cur = args[7]; *cur; cur++) {
    2.37 +			if (*cur == ' ') {
    2.38 +				cur++;
    2.39 +				break;
    2.40 +			}
    2.41 +		}
    2.42 +		realname = g_strdup(cur);
    2.43  		
    2.44  		keys = g_list_prepend(keys, "userhost");
    2.45  		values = g_list_prepend(values, userhost);
     3.1 --- a/libpurple/protocols/irc/parse.c
     3.2 +++ b/libpurple/protocols/irc/parse.c
     3.3 @@ -74,7 +74,7 @@
     3.4  	{ "331", "nc:",	irc_msg_topic },	/* No channel topic		*/
     3.5  	{ "332", "nc:", irc_msg_topic },	/* Channel topic		*/
     3.6  	{ "333", "*", irc_msg_ignore },		/* Topic setter stuff		*/
     3.7 -	{ "352", "nvcvnvvv:", irc_msg_who },/* Channel WHO			*/
     3.8 +	{ "352", "ncvvvnv:", irc_msg_who },	/* Channel WHO			*/
     3.9  	{ "353", "nvc:", irc_msg_names },	/* Names list			*/
    3.10  	{ "366", "nc:", irc_msg_names },	/* End of names			*/
    3.11  	{ "367", "ncnnv", irc_msg_ban },	/* Ban list			*/