comparison libpurple/protocols/irc/msgs.c @ 31081:e023b0378887

Prevent sending ISON messages larger than 512 bytes. Fixes #9692. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author jch@honig.net
date Thu, 30 Dec 2010 01:06:03 +0000
parents 1dcaaa68b245
children a8cc50c2279f
comparison
equal deleted inserted replaced
31080:40e5d8c3acca 31081:e023b0378887
759 759
760 if (!args || !args[1]) 760 if (!args || !args[1])
761 return; 761 return;
762 762
763 nicks = g_strsplit(args[1], " ", -1); 763 nicks = g_strsplit(args[1], " ", -1);
764
765 for (i = 0; nicks[i]; i++) { 764 for (i = 0; nicks[i]; i++) {
766 if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { 765 if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) {
767 continue; 766 continue;
768 } 767 }
769 ib->flag = TRUE; 768 ib->new_online_status = TRUE;
770 } 769 }
771
772 g_strfreev(nicks); 770 g_strfreev(nicks);
773 771
774 g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); 772 if (irc->ison_outstanding)
775 irc->ison_outstanding = FALSE; 773 irc_buddy_query(irc);
774
775 if (!irc->ison_outstanding)
776 g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc);
776 } 777 }
777 778
778 static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) 779 static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc)
779 { 780 {
780 PurpleConnection *gc = purple_account_get_connection(irc->account); 781 PurpleConnection *gc = purple_account_get_connection(irc->account);
781 PurpleBuddy *buddy = purple_find_buddy(irc->account, name); 782 PurpleBuddy *buddy = purple_find_buddy(irc->account, name);
782 783
783 if (!gc || !buddy) 784 if (!gc || !buddy)
784 return; 785 return;
785 786
786 if (ib->online && !ib->flag) { 787 if (ib->online && !ib->new_online_status) {
787 purple_prpl_got_user_status(irc->account, name, "offline", NULL); 788 purple_prpl_got_user_status(irc->account, name, "offline", NULL);
788 ib->online = FALSE; 789 ib->online = FALSE;
789 } else if (!ib->online && ib->flag) { 790 } else if (!ib->online && ib->new_online_status) {
790 purple_prpl_got_user_status(irc->account, name, "available", NULL); 791 purple_prpl_got_user_status(irc->account, name, "available", NULL);
791 ib->online = TRUE; 792 ib->online = TRUE;
792 } 793 }
793 } 794 }
794 795
835 836
836 userhost = irc_mask_userhost(from); 837 userhost = irc_mask_userhost(from);
837 purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE); 838 purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE);
838 839
839 if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { 840 if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) {
840 ib->flag = TRUE; 841 ib->new_online_status = TRUE;
841 irc_buddy_status(nick, ib, irc); 842 irc_buddy_status(nick, ib, irc);
842 } 843 }
843 844
844 g_free(userhost); 845 g_free(userhost);
845 g_free(nick); 846 g_free(nick);
1231 data[1] = args[0]; 1232 data[1] = args[0];
1232 /* XXX this should have an API, I shouldn't grab this directly */ 1233 /* XXX this should have an API, I shouldn't grab this directly */
1233 g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data); 1234 g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data);
1234 1235
1235 if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) { 1236 if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) {
1236 ib->flag = FALSE; 1237 ib->new_online_status = FALSE;
1237 irc_buddy_status(data[0], ib, irc); 1238 irc_buddy_status(data[0], ib, irc);
1238 } 1239 }
1239 g_free(data[0]); 1240 g_free(data[0]);
1240 1241
1241 return; 1242 return;