pidgin: d13ab585: fixes a crash and probably more correct ...

khc at pidgin.im khc at pidgin.im
Tue Jul 15 22:40:53 EDT 2008


-----------------------------------------------------------------
Revision: d13ab585f3e5a58e32ca8136c3b48ea767918734
Ancestor: f88720cd64b0f5bf56b150a66f55dc382710b235
Author: khc at pidgin.im
Date: 2008-07-16T02:39:15
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d13ab585f3e5a58e32ca8136c3b48ea767918734

Modified files:
        libpurple/protocols/msn/oim.c

ChangeLog: 

fixes a crash and probably more correct and definitely easier to understand
splitting. Fixes #6343. Thanks Dimmuxx for testing since I was too lazy to
do it myself


-------------- next part --------------
============================================================
--- libpurple/protocols/msn/oim.c	0d64864aa018bd11de963bbbc973f0c856048dac
+++ libpurple/protocols/msn/oim.c	2052f01081c4575e8d311ffdb22eff4a2995f424
@@ -274,22 +274,27 @@ msn_oim_msg_to_str(MsnOim *oim, const ch
 	char *oim_base64;
 	char *c;
 	int len;
+	size_t base64_len;
 
 	purple_debug_info("msn", "Encoding OIM Message...\n");
 	len = strlen(body);
 	c = oim_base64 = purple_base64_encode((const guchar *)body, len);
+	base64_len = strlen(oim_base64);
 	purple_debug_info("msn", "Encoded base64 body:{%s}\n", oim_base64);
 
 	oim_body = g_string_new(NULL);
 	g_string_printf(oim_body, MSN_OIM_MSG_TEMPLATE,
-	                oim->run_id, oim->send_seq);
+		oim->run_id, oim->send_seq, "");
 
-	len = ((len / 3) + 1) * 4 - 76;
-	while ((c - oim_base64) < len) {
-		g_string_append_len(oim_body, c, 76);
+#define OIM_LINE_LEN 76
+	while (base64_len > OIM_LINE_LEN) {
+		g_string_append_len(oim_body, c, OIM_LINE_LEN);
 		g_string_append_c(oim_body, '\n');
-		c += 76;
+		c += OIM_LINE_LEN;
+		base64_len -= OIM_LINE_LEN;
 	}
+#undef OIM_LINE_LEN
+
 	g_string_append(oim_body, c);
 
 	g_free(oim_base64);


More information about the Commits mailing list