Fix another possible remote crash bug in SILC. release-2.x.y
authorMark Doliner <markdoliner@pidgin.im>
Tue, 06 Dec 2011 06:50:18 +0000
branchrelease-2.x.y
changesetfa8d4132d071 pushlog
parent 9d90f89322ea
child 883a1b407408
Fix another possible remote crash bug in SILC.

This is the same change that Ethan made in 69372ee4f474efcca38b010bc2cdd61a917955f4,
but to a different function. Refs #14636
libpurple/protocols/silc/ops.c
      1.1 --- a/libpurple/protocols/silc/ops.c
      1.2 +++ b/libpurple/protocols/silc/ops.c
      1.3 @@ -332,10 +332,17 @@
      1.4  	}
      1.5  
      1.6  	if (flags & SILC_MESSAGE_FLAG_UTF8) {
      1.7 -		tmp = g_markup_escape_text((const char *)message, -1);
      1.8 +		const char *msg = (const char *)message;
      1.9 +		char *salvaged = NULL;
     1.10 +		if (!g_utf8_validate((const char *)message, -1, NULL)) {
     1.11 +			salvaged = purple_utf8_salvage((const char *)message);
     1.12 +			msg = salvaged;
     1.13 +		}
     1.14 +		tmp = g_markup_escape_text(msg, -1);
     1.15  		/* Send to Purple */
     1.16  		serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)),
     1.17  				 sender->nickname, 0, tmp, time(NULL));
     1.18 +		g_free(salvaged);
     1.19  		g_free(tmp);
     1.20  	}
     1.21  }