Mercurial > pidgin.yaz
comparison libpurple/protocols/irc/irc.c @ 31529: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 | 2a436e0ce977 |
children | fa88dc1dcabb 167ea4b4765c |
comparison
equal
deleted
inserted
replaced
31528:40e5d8c3acca | 31529:e023b0378887 |
---|---|
37 | 37 |
38 #include "irc.h" | 38 #include "irc.h" |
39 | 39 |
40 #define PING_TIMEOUT 60 | 40 #define PING_TIMEOUT 60 |
41 | 41 |
42 static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string); | 42 static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list); |
43 | 43 |
44 static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b); | 44 static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b); |
45 static GList *irc_status_types(PurpleAccount *account); | 45 static GList *irc_status_types(PurpleAccount *account); |
46 static GList *irc_actions(PurplePlugin *plugin, gpointer context); | 46 static GList *irc_actions(PurplePlugin *plugin, gpointer context); |
47 /* static GList *irc_chat_info(PurpleConnection *gc); */ | 47 /* static GList *irc_chat_info(PurpleConnection *gc); */ |
184 } | 184 } |
185 | 185 |
186 /* XXX I don't like messing directly with these buddies */ | 186 /* XXX I don't like messing directly with these buddies */ |
187 gboolean irc_blist_timeout(struct irc_conn *irc) | 187 gboolean irc_blist_timeout(struct irc_conn *irc) |
188 { | 188 { |
189 if (irc->ison_outstanding) { | |
190 return TRUE; | |
191 } | |
192 | |
193 g_hash_table_foreach(irc->buddies, (GHFunc)irc_ison_buddy_init, | |
194 (gpointer *)&irc->buddies_outstanding); | |
195 | |
196 irc_buddy_query(irc); | |
197 | |
198 return TRUE; | |
199 } | |
200 | |
201 void irc_buddy_query(struct irc_conn *irc) | |
202 { | |
203 GList *lp; | |
189 GString *string; | 204 GString *string; |
190 char *list, *buf; | 205 struct irc_buddy *ib; |
191 | 206 char *buf; |
192 if (irc->ison_outstanding) | |
193 return TRUE; | |
194 | 207 |
195 string = g_string_sized_new(512); | 208 string = g_string_sized_new(512); |
196 | 209 |
197 g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_append, (gpointer)string); | 210 while ((lp = g_list_first(irc->buddies_outstanding))) { |
198 | 211 ib = (struct irc_buddy *)lp->data; |
199 list = g_string_free(string, FALSE); | 212 if (string->len + strlen(ib->name) + 1 > 450) |
200 if (!list || !strlen(list)) { | 213 break; |
201 g_free(list); | 214 g_string_append_printf(string, "%s ", ib->name); |
202 return TRUE; | 215 ib->new_online_status = FALSE; |
203 } | 216 irc->buddies_outstanding = g_list_remove_link(irc->buddies_outstanding, lp); |
204 | 217 } |
205 buf = irc_format(irc, "vn", "ISON", list); | 218 |
206 g_free(list); | 219 if (string->len) { |
207 irc_send(irc, buf); | 220 buf = irc_format(irc, "vn", "ISON", string->str); |
208 g_free(buf); | 221 irc_send(irc, buf); |
209 | 222 g_free(buf); |
210 irc->ison_outstanding = TRUE; | 223 irc->ison_outstanding = TRUE; |
211 | 224 } else |
212 return TRUE; | 225 irc->ison_outstanding = FALSE; |
213 } | 226 |
214 | 227 g_string_free(string, TRUE); |
215 static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string) | 228 } |
216 { | 229 |
217 ib->flag = FALSE; | 230 static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list) |
218 g_string_append_printf(string, "%s ", name); | 231 { |
232 *list = g_list_append(*list, ib); | |
219 } | 233 } |
220 | 234 |
221 static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib) | 235 static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib) |
222 { | 236 { |
223 char *buf; | 237 char *buf; |
224 | 238 |
225 ib->flag = FALSE; | 239 if (irc->buddies_outstanding != NULL) { |
240 irc->buddies_outstanding = g_list_append(irc->buddies_outstanding, ib); | |
241 return; | |
242 } | |
243 | |
244 ib->new_online_status = FALSE; | |
226 buf = irc_format(irc, "vn", "ISON", ib->name); | 245 buf = irc_format(irc, "vn", "ISON", ib->name); |
227 irc_send(irc, buf); | 246 irc_send(irc, buf); |
228 g_free(buf); | 247 g_free(buf); |
229 } | 248 } |
230 | 249 |