/pidgin/main: 90201925e1fe: MXit: When generating clickable link...

Andrew Victor andrew.victor at mxit.com
Wed Apr 10 10:32:31 EDT 2013


Changeset: 90201925e1fe2397887b47691e40f267291d59c4
Author:	 Andrew Victor <andrew.victor at mxit.com>
Date:	 2013-04-10 16:32 +0200
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/90201925e1fe

Description:

MXit: When generating clickable links, rather use g_strdup_printf() than a statically-sized buffer.

diffstat:

 libpurple/protocols/mxit/markup.c |  17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diffs (39 lines):

diff --git a/libpurple/protocols/mxit/markup.c b/libpurple/protocols/mxit/markup.c
--- a/libpurple/protocols/mxit/markup.c
+++ b/libpurple/protocols/mxit/markup.c
@@ -133,27 +133,26 @@ static void hex_dump( const char* buf, i
 void mxit_add_html_link( struct RXMsgData* mx, const char* replydata, gboolean isStructured, const char* displaytext )
 {
 #ifdef	MXIT_LINK_CLICK
-	char	retstr[256];
-	gchar*	retstr64;
-	char	link[256];
-	int		len;
+	gchar*	link	= NULL;
+	gchar*	link64	= NULL;
 
 	/*
 	 * The link content is encoded as follows:
 	 *  MXIT_LINK_KEY | ACCOUNT_USER | ACCOUNT_PROTO | REPLY_TO | REPLY_FORMAT | REPLY_DATA
 	 */
-	len = g_snprintf( retstr, sizeof( retstr ), "%s|%s|%s|%s|%i|%s",
+	link = g_strdup_printf( "%s|%s|%s|%s|%i|%s",
 			MXIT_LINK_KEY,
 			purple_account_get_username( mx->session->acc ),
 			purple_account_get_protocol_id( mx->session->acc ),
 			mx->from,
 			isStructured ? 1 : 0,
 			replydata );
-	retstr64 = purple_base64_encode( (const unsigned char*) retstr, len );
-	g_snprintf( link, sizeof( link ), "%s%s", MXIT_LINK_PREFIX, retstr64 );
-	g_free( retstr64 );
+	link64 = purple_base64_encode( (const unsigned char*) link, strlen( link ) );
 
-	g_string_append_printf( mx->msg, "<a href=\"%s\">%s</a>", link, displaytext );
+	g_string_append_printf( mx->msg, "<a href=\"%s%s\">%s</a>", MXIT_LINK_PREFIX, link64, displaytext );
+
+	g_free( link64 );
+	g_free( link );
 #else
 	g_string_append_printf( mx->msg, "<b>%s</b>", replydata );
 #endif



More information about the Commits mailing list