Mercurial > pidgin
comparison libpurple/protocols/jabber/si.c @ 31445: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 | 40eb10487f87 |
children | a0b9ecdc98c4 |
comparison
equal
deleted
inserted
replaced
31444:a9e077fb65e9 | 31445:0123005d0fb8 |
---|---|
1681 { | 1681 { |
1682 JabberSIXfer *jsx; | 1682 JabberSIXfer *jsx; |
1683 PurpleXfer *xfer; | 1683 PurpleXfer *xfer; |
1684 xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail; | 1684 xmlnode *file, *feature, *x, *field, *option, *value, *thumbnail; |
1685 const char *stream_id, *filename, *filesize_c, *profile; | 1685 const char *stream_id, *filename, *filesize_c, *profile; |
1686 guint64 filesize_64 = 0; | |
1686 size_t filesize = 0; | 1687 size_t filesize = 0; |
1687 | 1688 |
1688 if(!(profile = xmlnode_get_attrib(si, "profile")) || | 1689 if(!(profile = xmlnode_get_attrib(si, "profile")) || |
1689 strcmp(profile, NS_SI_FILE_TRANSFER)) | 1690 strcmp(profile, NS_SI_FILE_TRANSFER)) |
1690 return; | 1691 return; |
1697 | 1698 |
1698 if(!(filename = xmlnode_get_attrib(file, "name"))) | 1699 if(!(filename = xmlnode_get_attrib(file, "name"))) |
1699 return; | 1700 return; |
1700 | 1701 |
1701 if((filesize_c = xmlnode_get_attrib(file, "size"))) | 1702 if((filesize_c = xmlnode_get_attrib(file, "size"))) |
1702 filesize = strtoul(filesize_c, NULL, 10); | 1703 filesize_64 = g_ascii_strtoull(filesize_c, NULL, 10); |
1704 /* TODO 3.0.0: When the core uses a guint64, this is redundant. | |
1705 * See #8477. | |
1706 */ | |
1707 if (filesize_64 > G_MAXSIZE) { | |
1708 /* Shoudl this pop up a warning? */ | |
1709 purple_debug_warning("jabber", "Unable to transfer file (too large)" | |
1710 " -- see #8477 for more details."); | |
1711 return; | |
1712 } | |
1713 filesize = filesize_64; | |
1703 | 1714 |
1704 if(!(feature = xmlnode_get_child(si, "feature"))) | 1715 if(!(feature = xmlnode_get_child(si, "feature"))) |
1705 return; | 1716 return; |
1706 | 1717 |
1707 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) | 1718 if(!(x = xmlnode_get_child_with_namespace(feature, "x", "jabber:x:data"))) |