comparison libpurple/protocols/jabber/presence.c @ 26863:0c1983abe991

Don't crash when a broken server sends us an occupant's presence with an empty resource. Refs #8361.
author Paul Aurich <paul@darkrain42.org>
date Sat, 02 May 2009 20:54:10 +0000
parents 5c4a4a0f5929
children 33f98d662db8
comparison
equal deleted inserted replaced
26862:5c4a4a0f5929 26863:0c1983abe991
664 664
665 665
666 if(type && !strcmp(type, "unavailable")) { 666 if(type && !strcmp(type, "unavailable")) {
667 gboolean nick_change = FALSE; 667 gboolean nick_change = FALSE;
668 668
669 /* If we haven't joined the chat yet, we don't care that someone 669 /* If the chat nick is invalid, we haven't yet joined, or we've
670 * left, or it was us leaving after we closed the chat */ 670 * already left (it was probably us leaving after we closed the
671 if (!chat->conv || chat->left) { 671 * chat), we don't care.
672 */
673 if (!jid->resource || !chat->conv || chat->left) {
672 if (chat->left && 674 if (chat->left &&
673 jid->resource && chat->handle && !strcmp(jid->resource, chat->handle)) 675 jid->resource && chat->handle && !strcmp(jid->resource, chat->handle))
674 jabber_chat_destroy(chat); 676 jabber_chat_destroy(chat);
675 jabber_id_free(jid); 677 jabber_id_free(jid);
676 g_free(status); 678 g_free(status);
727 status); 729 status);
728 jabber_chat_remove_handle(chat, jid->resource); 730 jabber_chat_remove_handle(chat, jid->resource);
729 } 731 }
730 } 732 }
731 } else { 733 } else {
734 /*
735 * XEP-0045 mandates the presence to include a resource (which is
736 * treated as the chat nick). Some non-compliant servers allow
737 * joining without a nick.
738 */
739 if (!jid->resource) {
740 jabber_id_free(jid);
741 g_free(avatar_hash);
742 g_free(nickname);
743 g_free(status);
744 return;
745 }
746
732 if(!chat->conv) { 747 if(!chat->conv) {
733 char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain); 748 char *room_jid = g_strdup_printf("%s@%s", jid->node, jid->domain);
734 chat->id = i++; 749 chat->id = i++;
735 chat->muc = muc; 750 chat->muc = muc;
736 chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid); 751 chat->conv = serv_got_joined_chat(js->gc, chat->id, room_jid);