/pidgin/main: 06278419c703: Fix for TALOS-CAN-0120

Andrew Victor andrew.victor at mxit.com
Mon Jun 20 20:09:57 EDT 2016


Changeset: 06278419c703cf6dd42a8add415480046ce9a05e
Author:	 Andrew Victor <andrew.victor at mxit.com>
Date:	 2016-06-03 12:07 -0500
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/06278419c703

Description:

Fix for TALOS-CAN-0120

diffstat:

 libpurple/protocols/mxit/chunk.c        |  72 ++++++++++++------------
 libpurple/protocols/mxit/chunk.h        |  76 ++++++++++++------------
 libpurple/protocols/mxit/filexfer.c     |   6 +-
 libpurple/protocols/mxit/filexfer.h     |   4 +-
 libpurple/protocols/mxit/protocol.c     |  98 ++++++++++++--------------------
 libpurple/protocols/mxit/protocol.h     |   6 +-
 libpurple/protocols/mxit/splashscreen.c |   2 +-
 libpurple/protocols/mxit/splashscreen.h |   2 +-
 8 files changed, 121 insertions(+), 145 deletions(-)

diffs (truncated from 607 to 300 lines):

diff --git a/libpurple/protocols/mxit/chunk.c b/libpurple/protocols/mxit/chunk.c
--- a/libpurple/protocols/mxit/chunk.c
+++ b/libpurple/protocols/mxit/chunk.c
@@ -168,7 +168,7 @@ static int get_int8( const char* chunkda
  *  @param value			The 16-bit value
  *  @return					The number of bytes extracted
  */
-static int get_int16( const char* chunkdata, short* value )
+static int get_int16( const char* chunkdata, unsigned short* value )
 {
 	*value = ntohs( *( (const short*) chunkdata ) );	/* host byte-order */
 
@@ -182,7 +182,7 @@ static int get_int16( const char* chunkd
  *  @param value			The 32-bit value
  *  @return					The number of bytes extracted
  */
-static int get_int32( const char* chunkdata, int* value )
+static int get_int32( const char* chunkdata, unsigned int* value )
 {
 	*value = ntohl( *( (const int*) chunkdata ) );	/* host byte-order */
 
@@ -230,9 +230,9 @@ static int get_data( const char* chunkda
  */
 static int get_utf8_string( const char* chunkdata, char* str, int maxstrlen )
 {
-	int		pos = 0;
-	short	len;
-	int		skip = 0;
+	int				pos = 0;
+	unsigned short	len;
+	int				skip = 0;
 
 	/* string length [2 bytes] */
 	pos += get_int16( &chunkdata[pos], &len );
@@ -263,9 +263,9 @@ static int get_utf8_string( const char* 
  *  @param fileid			A unique ID that identifies this file
  *  @return					The number of bytes encoded in the buffer
  */
-int mxit_chunk_create_reject( char* chunkdata, const char* fileid )
+size_t mxit_chunk_create_reject( char* chunkdata, const char* fileid )
 {
-	int		pos		= 0;
+	size_t	pos		= 0;
 
 	/* file id [8 bytes] */
 	pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN );
@@ -289,9 +289,9 @@ int mxit_chunk_create_reject( char* chun
  *  @param offset			The start offset in the file
  *  @return					The number of bytes encoded in the buffer
  */
-int mxit_chunk_create_get( char* chunkdata, const char* fileid, int filesize, int offset )
+size_t mxit_chunk_create_get( char* chunkdata, const char* fileid, size_t filesize, size_t offset )
 {
-	int		pos		= 0;
+	size_t	pos		= 0;
 
 	/* file id [8 bytes] */
 	pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN );
@@ -314,9 +314,9 @@ int mxit_chunk_create_get( char* chunkda
  *  @param status			The status of the file transfer (see chunk.h)
  *  @return					The number of bytes encoded in the buffer
  */
-int mxit_chunk_create_received( char* chunkdata, const char* fileid, unsigned char status )
+size_t mxit_chunk_create_received( char* chunkdata, const char* fileid, unsigned char status )
 {
-	int		pos		= 0;
+	size_t	pos		= 0;
 
 	/* file id [8 bytes] */
 	pos += add_data( &chunkdata[pos], fileid, MXIT_CHUNK_FILEID_LEN );
@@ -338,9 +338,9 @@ int mxit_chunk_create_received( char* ch
  *  @param datalen			The size of the file contents
  *  @return					The number of bytes encoded in the buffer
  */
-int mxit_chunk_create_senddirect( char* chunkdata, const char* username, const char* filename, const unsigned char* data, int datalen )
+size_t mxit_chunk_create_senddirect( char* chunkdata, const char* username, const char* filename, const unsigned char* data, size_t datalen )
 {
-	int			pos		= 0;
+	size_t		pos		= 0;
 	const char*	mime	= NULL;
 
 	/* data length [4 bytes] */
@@ -380,10 +380,10 @@ int mxit_chunk_create_senddirect( char* 
  *  @param datalen			The size of the avatar data
  *  @return					The number of bytes encoded in the buffer
  */
-int mxit_chunk_create_set_avatar( char* chunkdata, const unsigned char* data, int datalen )
+size_t mxit_chunk_create_set_avatar( char* chunkdata, const unsigned char* data, size_t datalen )
 {
 	char	fileid[MXIT_CHUNK_FILEID_LEN];
-	int			pos = 0;
+	size_t	pos = 0;
 
 	/* id [8 bytes] */
 	memset( &fileid, 0, sizeof( fileid ) );		/* set to 0 for file upload */
@@ -410,9 +410,9 @@ int mxit_chunk_create_set_avatar( char* 
  *  @param avatarId			The Id of the avatar image (as string)
  *  @return					The number of bytes encoded in the buffer
  */
-int mxit_chunk_create_get_avatar( char* chunkdata, const char* mxitId, const char* avatarId )
+size_t mxit_chunk_create_get_avatar( char* chunkdata, const char* mxitId, const char* avatarId )
 {
-	int			pos = 0;
+	size_t	pos = 0;
 
 	/* number of avatars [4 bytes] */
 	pos += add_int32( &chunkdata[pos], 1 );
@@ -450,11 +450,11 @@ int mxit_chunk_create_get_avatar( char* 
  *  @param datalen			The length of the chunked data
  *  @param offer			Decoded offerfile information
  */
-void mxit_chunk_parse_offer( char* chunkdata, int datalen, struct offerfile_chunk* offer )
+void mxit_chunk_parse_offer( char* chunkdata, size_t datalen, struct offerfile_chunk* offer )
 {
-	int			pos			= 0;
+	int		pos			= 0;
 
-	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_offer (%i bytes)\n", datalen );
+	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_offer (%zu bytes)\n", datalen );
 
 	/* id [8 bytes] */
 	pos += get_data( &chunkdata[pos], offer->fileid, 8);
@@ -493,11 +493,11 @@ void mxit_chunk_parse_offer( char* chunk
  *  @param datalen			The length of the chunked data
  *  @param offer			Decoded getfile information
  */
-void mxit_chunk_parse_get( char* chunkdata, int datalen, struct getfile_chunk* getfile )
+void mxit_chunk_parse_get( char* chunkdata, size_t datalen, struct getfile_chunk* getfile )
 {
 	int			pos			= 0;
 
-	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_file (%i bytes)\n", datalen );
+	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_file (%zu bytes)\n", datalen );
 
 	/* id [8 bytes] */
 	pos += get_data( &chunkdata[pos], getfile->fileid, 8 );
@@ -523,11 +523,11 @@ void mxit_chunk_parse_get( char* chunkda
  *  @param datalen			The length of the chunked data
  *  @param splash			Decoded splash image information
  */
-static void mxit_chunk_parse_splash( char* chunkdata, int datalen, struct splash_chunk* splash )
+static void mxit_chunk_parse_splash( char* chunkdata, size_t datalen, struct splash_chunk* splash )
 {
 	int			pos			= 0;
 
-	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_splash (%i bytes)\n", datalen );
+	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_splash (%zu bytes)\n", datalen );
 
 	/* anchor [1 byte] */
 	pos += get_int8( &chunkdata[pos], &(splash->anchor) );
@@ -553,12 +553,12 @@ static void mxit_chunk_parse_splash( cha
  *  @param datalen			The length of the chunked data
  *  @param offer			Decoded custom resource
  */
-void mxit_chunk_parse_cr( char* chunkdata, int datalen, struct cr_chunk* cr )
+void mxit_chunk_parse_cr( char* chunkdata, size_t datalen, struct cr_chunk* cr )
 {
-	int			pos			= 0;
-	int			chunklen	= 0;
+	int				pos			= 0;
+	unsigned int	chunklen	= 0;
 
-	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_cr (%i bytes)\n", datalen );
+	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_cr (%zu bytes)\n", datalen );
 
 	/* id [UTF-8] */
 	pos += get_utf8_string( &chunkdata[pos], cr->id, sizeof( cr->id ) );
@@ -614,12 +614,12 @@ void mxit_chunk_parse_cr( char* chunkdat
  *  @param datalen			The length of the chunked data
  *  @param sendfile			Decoded sendfile information
  */
-void mxit_chunk_parse_sendfile( char* chunkdata, int datalen, struct sendfile_chunk* sendfile )
+void mxit_chunk_parse_sendfile( char* chunkdata, size_t datalen, struct sendfile_chunk* sendfile )
 {
-	int			pos		= 0;
-	short		entries	= 0;
+	int				pos		= 0;
+	unsigned short	entries	= 0;
 
-	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_sendfile (%i bytes)\n", datalen );
+	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_sendfile (%zu bytes)\n", datalen );
 
 	/* number of entries [2 bytes] */
 	pos += get_int16( &chunkdata[pos], &entries );
@@ -645,12 +645,12 @@ void mxit_chunk_parse_sendfile( char* ch
  *  @param datalen			The length of the chunked data
  *  @param avatar			Decoded avatar information
  */
-void mxit_chunk_parse_get_avatar( char* chunkdata, int datalen, struct getavatar_chunk* avatar )
+void mxit_chunk_parse_get_avatar( char* chunkdata, size_t datalen, struct getavatar_chunk* avatar )
 {
-	int			pos			= 0;
-	int			numfiles	= 0;
+	int				pos			= 0;
+	unsigned int	numfiles	= 0;
 
-	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_get_avatar (%i bytes)\n", datalen );
+	purple_debug_info( MXIT_PLUGIN_ID, "mxit_chunk_parse_get_avatar (%zu bytes)\n", datalen );
 
 	/* number of files [4 bytes] */
 	pos += get_int32( &chunkdata[pos], &numfiles );
diff --git a/libpurple/protocols/mxit/chunk.h b/libpurple/protocols/mxit/chunk.h
--- a/libpurple/protocols/mxit/chunk.h
+++ b/libpurple/protocols/mxit/chunk.h
@@ -103,22 +103,22 @@ static inline gchar* chunk_data( gchar* 
  * Offer File chunk (6).
  */
 struct offerfile_chunk {
-	char	fileid[MXIT_CHUNK_FILEID_LEN];
-	char	username[MXIT_CP_MAX_JID_LEN + 1];
-	int		filesize;
-	char	filename[FILENAME_MAX];
-	char	mimetype[64];
+	char			fileid[MXIT_CHUNK_FILEID_LEN];
+	char			username[MXIT_CP_MAX_JID_LEN + 1];
+	unsigned int	filesize;
+	char			filename[FILENAME_MAX];
+	char			mimetype[64];
 };
 
 /*
  * Get File chunk (8) response.
  */
 struct getfile_chunk {
-	char	fileid[MXIT_CHUNK_FILEID_LEN];
-	int		offset;
-	int		length;
-	int		crc;
-	char*	data;
+	char			fileid[MXIT_CHUNK_FILEID_LEN];
+	unsigned int	offset;
+	unsigned int	length;
+	unsigned int	crc;
+	char*			data;
 };
 
 /*
@@ -135,11 +135,11 @@ struct cr_chunk {
  * Splash Image chunk (2)
  */
 struct splash_chunk {
-	char	anchor;
-	char	showtime;
-	int		bgcolor;
-	char*	data;
-	int		datalen;
+	char			anchor;
+	char			showtime;
+	unsigned int	bgcolor;
+	char*			data;
+	unsigned int	datalen;
 };
 
 /*
@@ -153,40 +153,40 @@ struct splash_click_chunk {
  * Get Avatar chunk (14) response.
  */
 struct getavatar_chunk {
-	char	mxitid[50];
-	char	avatarid[64];
-	char	format[16];
-	char	bitdepth;
-	int		crc;
-	int		width;
-	int		height;
-	int		length;
-	char*	data;
+	char			mxitid[50];
+	char			avatarid[64];
+	char			format[16];
+	char			bitdepth;
+	unsigned int	crc;
+	unsigned int	width;
+	unsigned int	height;
+	unsigned int	length;
+	char*			data;
 };
 
 /*
  * Send File Direct chunk (10) response.
  */
 struct sendfile_chunk {
-	char	username[MXIT_CP_MAX_JID_LEN + 1];
-	int		status;
-	char	statusmsg[1024];
+	char			username[MXIT_CP_MAX_JID_LEN + 1];
+	unsigned int	status;
+	char			statusmsg[1024];
 };
 
 /* Encode chunk */
-int mxit_chunk_create_senddirect( char* chunkdata, const char* username, const char* filename, const unsigned char* data, int datalen );
-int mxit_chunk_create_reject( char* chunkdata, const char* fileid );
-int mxit_chunk_create_get( char* chunkdata, const char* fileid, int filesize, int offset );
-int mxit_chunk_create_received( char* chunkdata, const char* fileid, unsigned char status );
-int mxit_chunk_create_set_avatar( char* chunkdata, const unsigned char* data, int datalen );
-int mxit_chunk_create_get_avatar( char* chunkdata, const char* mxitId, const char* avatarId );
+size_t mxit_chunk_create_senddirect( char* chunkdata, const char* username, const char* filename, const unsigned char* data, size_t datalen );
+size_t mxit_chunk_create_reject( char* chunkdata, const char* fileid );
+size_t mxit_chunk_create_get( char* chunkdata, const char* fileid, size_t filesize, size_t offset );



More information about the Commits mailing list