pidgin: 3993504a: Don't crash when a broken server sends u...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sat May 2 17:15:33 EDT 2009
-----------------------------------------------------------------
Revision: 3993504a85f5cbebaeace03466d79cda9803f240
Ancestor: 1a0227aa4f285cab8af8faf30127059fa71ce208
Author: darkrain42 at pidgin.im
Date: 2009-05-02T20:54:10
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/3993504a85f5cbebaeace03466d79cda9803f240
Modified files:
libpurple/protocols/jabber/presence.c
ChangeLog:
Don't crash when a broken server sends us an occupant's presence with an
empty resource. Refs #8361.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/presence.c 4e220eb9ec21379344345205f41487455a850208
+++ libpurple/protocols/jabber/presence.c 8527f75e4713317f89e960cdc10d1edecc73f87d
@@ -666,9 +666,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);
@@ -729,6 +731,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) {
char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain);
chat->id = i++;
More information about the Commits
mailing list