# HG changeset patch # User andrew.victor@mxit.com # Date 1313255519 0 # Node ID ff8ab76da6bbf0db8c1613b884a66c8c43e851af # Parent 9ad5fcde4af429742908e6e8f98519766f56cdf0 Remove ISO10126 padding when decrypting an incoming transport-encrypted message. diff -r 9ad5fcde4af4 -r ff8ab76da6bb libpurple/protocols/mxit/cipher.c --- a/libpurple/protocols/mxit/cipher.c Sat Aug 13 16:29:21 2011 +0000 +++ b/libpurple/protocols/mxit/cipher.c Sat Aug 13 17:11:59 2011 +0000 @@ -149,7 +149,6 @@ Decrypt( (unsigned char*) raw_message + i, (unsigned char*) exkey, (unsigned char*) block ); g_string_append_len( decoded, block, 16 ); } - g_free( raw_message ); purple_debug_info( MXIT_PLUGIN_ID, "decrypted: '%s'\n", decoded->str ); @@ -159,10 +158,16 @@ g_string_free( decoded, TRUE ); return NULL; /* message could not be decoded */ } - g_string_erase( decoded, 0, strlen( SECRET_HEADER ) ); /* remove header */ /* remove ISO10126 padding */ -// TODO + { + /* last byte indicates the number of padding bytes */ + unsigned int padding = decoded->str[decoded->len - 1]; + g_string_truncate( decoded, decoded->len - padding ); + } + + /* remove encryption header */ + g_string_erase( decoded, 0, strlen( SECRET_HEADER ) ); return g_string_free( decoded, FALSE ); }