changeset 31896:0123005d0fb8

jabber: Slightly better handling of large files (on receipt). Refs #1185, because the commenter there noted the issue with XMPP.
author Paul Aurich <paul@darkrain42.org>
date Sat, 02 Apr 2011 18:03:54 +0000
parents a9e077fb65e9
children 1a248102e437 a0b9ecdc98c4 d4b7770324f8
files libpurple/protocols/jabber/si.c
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/jabber/si.c	Thu Mar 31 04:41:27 2011 +0000
+++ b/libpurple/protocols/jabber/si.c	Sat Apr 02 18:03:54 2011 +0000
@@ -1683,6 +1683,7 @@
 	PurpleXfer *xfer;
 	xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail;
 	const char *stream_id, *filename, *filesize_c, *profile;
+	guint64 filesize_64 = 0;
 	size_t filesize = 0;
 
 	if(!(profile = xmlnode_get_attrib(si, "profile")) ||
@@ -1699,7 +1700,17 @@
 		return;
 
 	if((filesize_c = xmlnode_get_attrib(file, "size")))
-		filesize = strtoul(filesize_c, NULL, 10);
+		filesize_64 = g_ascii_strtoull(filesize_c, NULL, 10);
+	/* TODO 3.0.0: When the core uses a guint64, this is redundant.
+	 * See #8477.
+	 */
+	if (filesize_64 > G_MAXSIZE) {
+		/* Shoudl this pop up a warning? */
+		purple_debug_warning("jabber", "Unable to transfer file (too large)"
+		                     " -- see #8477 for more details.");
+		return;
+	}
+	filesize = filesize_64;
 
 	if(!(feature = xmlnode_get_child(si, "feature")))
 		return;