Mercurial > pidgin.yaz
changeset 23744:3c3032be12de
Restrict buddy icon downloads from arbitrary urls to 200kB.
Also, cancel buddy icon downloads when disconnecting.
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 01:58:27 +0000 |
parents | de8f2d3e538a |
children | 80ddf59e1585 |
files | libpurple/protocols/jabber/buddy.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h |
diffstat | 3 files changed, 25 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c Fri Aug 08 23:34:27 2008 +0000 +++ b/libpurple/protocols/jabber/buddy.c Sat Aug 09 01:58:27 2008 +0000 @@ -37,6 +37,8 @@ #include "pep.h" #include "adhoccommands.h" +#define MAX_HTTP_BUDDYICON_BYTES (200 * 1024) + typedef struct { long idle_seconds; } JabberBuddyInfoResource; @@ -1535,18 +1537,27 @@ } } if(goodinfo) { - const char *url = xmlnode_get_attrib(goodinfo,"url"); + const char *url = xmlnode_get_attrib(goodinfo, "url"); const char *id = xmlnode_get_attrib(goodinfo,"id"); /* the avatar might either be stored in a pep node, or on a HTTP/HTTPS URL */ if(!url) jabber_pep_request_item(js, from, AVATARNAMESPACEDATA, id, do_buddy_avatar_update_data); else { + PurpleUtilFetchUrlData *url_data; JabberBuddyAvatarUpdateURLInfo *info = g_new0(JabberBuddyAvatarUpdateURLInfo, 1); info->js = js; - info->from = g_strdup(from); - info->id = g_strdup(id); - purple_util_fetch_url(url, TRUE, NULL, TRUE, do_buddy_avatar_update_fromurl, info); + + url_data = purple_util_fetch_url_len(url, TRUE, NULL, TRUE, + MAX_HTTP_BUDDYICON_BYTES, + do_buddy_avatar_update_fromurl, info); + if (url_data) { + info->from = g_strdup(from); + info->id = g_strdup(id); + js->url_datas = g_slist_prepend(js->url_datas, url_data); + } else + g_free(info); + } } }
--- a/libpurple/protocols/jabber/jabber.c Fri Aug 08 23:34:27 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.c Sat Aug 09 01:58:27 2008 +0000 @@ -1322,6 +1322,11 @@ js->bs_proxies = g_list_delete_link(js->bs_proxies, js->bs_proxies); } + while(js->url_datas) { + purple_util_fetch_url_cancel(js->url_datas->data); + js->url_datas = g_slist_delete_link(js->url_datas, js->url_datas); + } + g_free(js->stream_id); if(js->user) jabber_id_free(js->user);
--- a/libpurple/protocols/jabber/jabber.h Fri Aug 08 23:34:27 2008 +0000 +++ b/libpurple/protocols/jabber/jabber.h Sat Aug 09 01:58:27 2008 +0000 @@ -236,6 +236,11 @@ PurpleSrvResponse *srv_rec; guint srv_rec_idx; guint max_srv_rec_idx; + /** + * This linked list contains PurpleUtilFetchUrlData structs + * for when we lookup buddy icons from a url + */ + GSList *url_datas; }; typedef gboolean (JabberFeatureEnabled)(JabberStream *js, const gchar *shortname, const gchar *namespace);