pidgin: 3851a1cf: Prevent sending ISON messages larger tha...
rekkanoryo at pidgin.im
rekkanoryo at pidgin.im
Wed Dec 29 20:31:18 EST 2010
----------------------------------------------------------------------
Revision: 3851a1cf3c16073e17c31b6b23194cb26ce1be6f
Parent: 322ea5e330b2ce8591329c42931c0ad8dbbbf2cf
Author: jch at honig.net
Date: 12/29/10 20:06:03
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/3851a1cf3c16073e17c31b6b23194cb26ce1be6f
Changelog:
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Changes against parent 322ea5e330b2ce8591329c42931c0ad8dbbbf2cf
patched COPYRIGHT
patched ChangeLog
patched libpurple/protocols/irc/irc.c
patched libpurple/protocols/irc/irc.h
patched libpurple/protocols/irc/msgs.c
-------------- next part --------------
============================================================
--- ChangeLog f9c98e7df9b9b56f14e81a0783da83ea9851e705
+++ ChangeLog 55c168b29c37554c0f1fa684b7de0c3798b32c9d
@@ -1,6 +1,9 @@ version 2.7.10 (??/??/????):
Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
version 2.7.10 (??/??/????):
+ IRC:
+ * Don't send ISON messages longer than 512 bytes. (Jeffrey Honig) (#9692)
+
libpurple:
* Stop sending audio when placing a call on hold. (Jakub Adam) (#13032)
* Stop translating gpointers to ints in the dbus API. This removes
============================================================
--- libpurple/protocols/irc/irc.c 7f37c323a474e7e1dee1dbd1a9b11da76deeae9c
+++ libpurple/protocols/irc/irc.c 9824f680d433623dac1d94bb4e8b6fead8d0e597
@@ -39,7 +39,7 @@
#define PING_TIMEOUT 60
-static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string);
+static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list);
static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b);
static GList *irc_status_types(PurpleAccount *account);
@@ -186,43 +186,62 @@ gboolean irc_blist_timeout(struct irc_co
/* XXX I don't like messing directly with these buddies */
gboolean irc_blist_timeout(struct irc_conn *irc)
{
- GString *string;
- char *list, *buf;
+ if (irc->ison_outstanding) {
+ return TRUE;
+ }
- if (irc->ison_outstanding)
- return TRUE;
+ g_hash_table_foreach(irc->buddies, (GHFunc)irc_ison_buddy_init,
+ (gpointer *)&irc->buddies_outstanding);
- string = g_string_sized_new(512);
+ irc_buddy_query(irc);
- g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_append, (gpointer)string);
+ return TRUE;
+}
- list = g_string_free(string, FALSE);
- if (!list || !strlen(list)) {
- g_free(list);
- return TRUE;
- }
+void irc_buddy_query(struct irc_conn *irc)
+{
+ GList *lp;
+ GString *string;
+ struct irc_buddy *ib;
+ char *buf;
- buf = irc_format(irc, "vn", "ISON", list);
- g_free(list);
- irc_send(irc, buf);
- g_free(buf);
+ string = g_string_sized_new(512);
- irc->ison_outstanding = TRUE;
+ while ((lp = g_list_first(irc->buddies_outstanding))) {
+ ib = (struct irc_buddy *)lp->data;
+ if (string->len + strlen(ib->name) + 1 > 450)
+ break;
+ g_string_append_printf(string, "%s ", ib->name);
+ ib->new_online_status = FALSE;
+ irc->buddies_outstanding = g_list_remove_link(irc->buddies_outstanding, lp);
+ }
- return TRUE;
+ if (string->len) {
+ buf = irc_format(irc, "vn", "ISON", string->str);
+ irc_send(irc, buf);
+ g_free(buf);
+ irc->ison_outstanding = TRUE;
+ } else
+ irc->ison_outstanding = FALSE;
+
+ g_string_free(string, TRUE);
}
-static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string)
+static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list)
{
- ib->flag = FALSE;
- g_string_append_printf(string, "%s ", name);
+ *list = g_list_append(*list, ib);
}
static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib)
{
char *buf;
- ib->flag = FALSE;
+ if (irc->buddies_outstanding != NULL) {
+ irc->buddies_outstanding = g_list_append(irc->buddies_outstanding, ib);
+ return;
+ }
+
+ ib->new_online_status = FALSE;
buf = irc_format(irc, "vn", "ISON", ib->name);
irc_send(irc, buf);
g_free(buf);
============================================================
--- libpurple/protocols/irc/irc.h b74849f9927175a474cb318bbdde9d2b130b992e
+++ libpurple/protocols/irc/irc.h df6b06ec27843e6a773c86340988fbd1dddc30a7
@@ -58,6 +58,7 @@ struct irc_conn {
GHashTable *buddies;
gboolean ison_outstanding;
+ GList *buddies_outstanding;
char *inbuf;
int inbuflen;
@@ -97,6 +98,7 @@ struct irc_buddy {
char *name;
gboolean online;
gboolean flag;
+ gboolean new_online_status;
int ref;
};
@@ -104,6 +106,7 @@ gboolean irc_blist_timeout(struct irc_co
int irc_send(struct irc_conn *irc, const char *buf);
gboolean irc_blist_timeout(struct irc_conn *irc);
+void irc_buddy_query(struct irc_conn *irc);
char *irc_escape_privmsg(const char *text, gssize length);
============================================================
--- libpurple/protocols/irc/msgs.c 711c291ec1444e4cb5402313775691a4792cf15d
+++ libpurple/protocols/irc/msgs.c 0cd2a14587598f755b2ab7b88f5f532c3512b6d6
@@ -761,18 +761,19 @@ void irc_msg_ison(struct irc_conn *irc,
return;
nicks = g_strsplit(args[1], " ", -1);
-
for (i = 0; nicks[i]; i++) {
if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) {
continue;
}
- ib->flag = TRUE;
+ ib->new_online_status = TRUE;
}
+ g_strfreev(nicks);
- g_strfreev(nicks);
+ if (irc->ison_outstanding)
+ irc_buddy_query(irc);
- g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc);
- irc->ison_outstanding = FALSE;
+ if (!irc->ison_outstanding)
+ g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc);
}
static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc)
@@ -783,10 +784,10 @@ static void irc_buddy_status(char *name,
if (!gc || !buddy)
return;
- if (ib->online && !ib->flag) {
+ if (ib->online && !ib->new_online_status) {
purple_prpl_got_user_status(irc->account, name, "offline", NULL);
ib->online = FALSE;
- } else if (!ib->online && ib->flag) {
+ } else if (!ib->online && ib->new_online_status) {
purple_prpl_got_user_status(irc->account, name, "available", NULL);
ib->online = TRUE;
}
@@ -837,7 +838,7 @@ void irc_msg_join(struct irc_conn *irc,
purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE);
if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) {
- ib->flag = TRUE;
+ ib->new_online_status = TRUE;
irc_buddy_status(nick, ib, irc);
}
@@ -1233,7 +1234,7 @@ void irc_msg_quit(struct irc_conn *irc,
g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data);
if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) {
- ib->flag = FALSE;
+ ib->new_online_status = FALSE;
irc_buddy_status(data[0], ib, irc);
}
g_free(data[0]);
============================================================
--- COPYRIGHT 815f2a68fae77c33f6d31d1c09425a6271e99e4f
+++ COPYRIGHT e20301a5c1d18078422927d1976543909d8f2453
@@ -223,6 +223,7 @@ Joshua Honeycutt
Andrew Hoffman
Iain Holmes
Joshua Honeycutt
+Jeffrey Honig
Nigel Horne
Jensen Hornick
Juanjo Molinero Horno
More information about the Commits
mailing list