pidgin: 26acfe7e: jabber: Don't use a static array when it...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Wed Jun 16 21:55:59 EDT 2010


-----------------------------------------------------------------
Revision: 26acfe7eacc1bdb290a00149b828ed102e023284
Ancestor: ecaf7f1b35c3334cbb085a7f493c59291f8fd8a9
Author: darkrain42 at pidgin.im
Date: 2010-06-17T01:45:44
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/26acfe7eacc1bdb290a00149b828ed102e023284

Modified files:
        libpurple/protocols/jabber/data.c

ChangeLog: 

jabber: Don't use a static array when it might not be sufficient.

JabberData:cid may come from the network, in which case the one I changed
here would result in truncation.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/data.c	3470d9f005c744dcb9ddb35040dc41b653c9f082
+++ libpurple/protocols/jabber/data.c	668dd94891f8de9d3f3e835459909a4e8e89c7bc
@@ -43,7 +43,7 @@ jabber_data_create_from_data(gconstpoint
 {
 	JabberData *data;
 	gchar *checksum;
-	gchar cid[256];
+	gchar cid[256]; /* "Big enough" for a SHA1 hex hash value */
 
 	g_return_val_if_fail(rawdata != NULL, NULL);
 	g_return_val_if_fail(size > 0, NULL);
@@ -191,15 +191,17 @@ jabber_data_get_xhtml_im(const JabberDat
 jabber_data_get_xhtml_im(const JabberData *data, const gchar *alt)
 {
 	xmlnode *img;
-	char src[128];
+	char *src;
 
 	g_return_val_if_fail(data != NULL, NULL);
 	g_return_val_if_fail(alt != NULL, NULL);
 
 	img = xmlnode_new("img");
 	xmlnode_set_attrib(img, "alt", alt);
-	g_snprintf(src, sizeof(src), "cid:%s", data->cid);
+
+	src = g_strconcat("cid:", data->cid, NULL);
 	xmlnode_set_attrib(img, "src", src);
+	g_free(src);
 
 	return img;
 }


More information about the Commits mailing list