pidgin.2.5.6: 49f94bb2: *** Plucked rev 3993504a (darkrain42 at pid...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sat May 2 17:15:34 EDT 2009


-----------------------------------------------------------------
Revision: 49f94bb29abf4c87236751b580f99998ca5a80ba
Ancestor: 05325ad06b473a5932ac8cecbf0f96297eb86246
Author: darkrain42 at pidgin.im
Date: 2009-05-02T21:08:59
Branch: im.pidgin.pidgin.2.5.6
URL: http://d.pidgin.im/viewmtn/revision/info/49f94bb29abf4c87236751b580f99998ca5a80ba

Modified files:
        libpurple/protocols/jabber/presence.c

ChangeLog: 

*** Plucked rev 3993504a (darkrain42 at pidgin.im):
Don't crash when a broken server sends us an occupant's presence with an
empty resource. Closes #8361.


-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/presence.c	93c18869585feb24d9fae02c395caa6e839f8303
+++ libpurple/protocols/jabber/presence.c	dafa41b0cf3201707c02e7d389755018cc711e2c
@@ -601,9 +601,11 @@ void jabber_presence_parse(JabberStream 
 		if(type && !strcmp(type, "unavailable")) {
 			gboolean nick_change = FALSE;
 
-			/* If we haven't joined the chat yet, we don't care that someone
-			 * left, or it was us leaving after we closed the chat */
-			if (!chat->conv || chat->left) {
+			/* If the chat nick is invalid, we haven't yet joined, or we've
+			 * already left (it was probably us leaving after we closed the
+			 * chat), we don't care.
+			 */
+			if (!jid->resource || !chat->conv || chat->left) {
 				if (chat->left &&
 						jid->resource && chat->handle && !strcmp(jid->resource, chat->handle))
 					jabber_chat_destroy(chat);
@@ -664,6 +666,19 @@ void jabber_presence_parse(JabberStream 
 				}
 			}
 		} else {
+			/*
+			 * XEP-0045 mandates the presence to include a resource (which is
+			 * treated as the chat nick). Some non-compliant servers allow
+			 * joining without a nick.
+			 */
+			if (!jid->resource) {
+				jabber_id_free(jid);
+				g_free(avatar_hash);
+				g_free(nickname);
+				g_free(status);
+				return;
+			}
+
 			if(!chat->conv) {
 				chat->id = i++;
 				chat->muc = muc;


More information about the Commits mailing list