pidgin: 72c558ad: jabber: Stricter parsing of a BoB data s...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Mon Aug 31 16:11:49 EDT 2009
-----------------------------------------------------------------
Revision: 72c558ad4f7ad4f6c3ef1347e9d202cebdfaed83
Ancestor: fff08980f18a8b4ce7302669680621243d2b8853
Author: darkrain42 at pidgin.im
Date: 2009-08-31T20:06:36
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/72c558ad4f7ad4f6c3ef1347e9d202cebdfaed83
Modified files:
libpurple/protocols/jabber/data.c
ChangeLog:
jabber: Stricter parsing of a BoB data stanza
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/data.c d86021529f80b4f728480cf8462bec5d4501c416
+++ libpurple/protocols/jabber/data.c 55f2706b6e6654b4e95196a676bd2bdcb4783cc3
@@ -56,32 +56,43 @@ jabber_data_create_from_xml(xmlnode *tag
JabberData *
jabber_data_create_from_xml(xmlnode *tag)
{
- JabberData *data = g_new0(JabberData, 1);
- gsize size;
- gpointer raw_data = NULL;
+ JabberData *data;
+ gchar *raw_data = NULL;
+ const gchar *cid, *type;
- if (data == NULL) {
- purple_debug_error("jabber", "Could not allocate data object\n");
- g_free(data);
+ /* check if this is a "data" tag */
+ if (strcmp(tag->name, "data") != 0) {
+ purple_debug_error("jabber", "Invalid data element\n");
return NULL;
}
- /* check if this is a "data" tag */
- if (strcmp(tag->name, "data") != 0) {
- purple_debug_error("jabber", "Invalid data element");
- g_free(data);
+ cid = xmlnode_get_attrib(tag, "cid");
+ type = xmlnode_get_attrib(tag, "type");
+
+ if (!cid || !type) {
+ purple_debug_error("jabber", "cid or type missing\n");
return NULL;
}
- data->cid = g_strdup(xmlnode_get_attrib(tag, "cid"));
- data->type = g_strdup(xmlnode_get_attrib(tag, "type"));
-
raw_data = xmlnode_get_data(tag);
- data->data = purple_base64_decode(raw_data, &size);
- data->size = size;
+ if (raw_data == NULL || *raw_data == '\0') {
+ g_free(raw_data);
+ return NULL;
+ }
+ data = g_new0(JabberData, 1);
+ data->data = purple_base64_decode(raw_data, &data->size);
g_free(raw_data);
+ if (data->data == NULL) {
+ purple_debug_error("jabber", "Malformed base64 data\n");
+ g_free(data);
+ return NULL;
+ }
+
+ data->cid = g_strdup(cid);
+ data->type = g_strdup(type);
+
return data;
}
More information about the Commits
mailing list