/pidgin/main: e6159ad42c4c: Fix TALOS-CAN-0141

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


Changeset: e6159ad42c4c557adb8aaae8e08aff084ef8bb8e
Author:	 Andrew Victor <andrew.victor at mxit.com>
Date:	 2016-06-02 12:49 -0500
Branch:	 release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/e6159ad42c4c

Description:

Fix TALOS-CAN-0141

diffstat:

 libpurple/protocols/mxit/protocol.c |  22 ++++++++++++++++++++--
 libpurple/protocols/mxit/roster.c   |   4 ----
 2 files changed, 20 insertions(+), 6 deletions(-)

diffs (60 lines):

diff --git a/libpurple/protocols/mxit/protocol.c b/libpurple/protocols/mxit/protocol.c
--- a/libpurple/protocols/mxit/protocol.c
+++ b/libpurple/protocols/mxit/protocol.c
@@ -1691,6 +1691,24 @@ static short mxit_parse_presence( const 
 
 
 /*------------------------------------------------------------------------
+ * Parse the received mood value, and ensure that it is supported.
+ *
+ *  @param value		The received mood value.
+ *  @return				A valid mood value.
+ */
+static short mxit_parse_mood( const char* value )
+{
+	short mood = atoi( value );
+
+	/* ensure that the mood value is valid */
+	if ( ( mood >= MXIT_MOOD_NONE ) && ( mood <= MXIT_MOOD_STRESSED ) )
+		return mood;
+
+	return MXIT_MOOD_NONE;
+}
+
+
+/*------------------------------------------------------------------------
  * Process a received contact update packet.
  *
  *  @param session		The MXit session object
@@ -1723,7 +1741,7 @@ static void mxit_parse_cmd_contact( stru
 
 		contact->presence = mxit_parse_presence( rec->fields[3]->data );
 		contact->type = atoi( rec->fields[4]->data );
-		contact->mood = atoi( rec->fields[5]->data );
+		contact->mood = mxit_parse_mood( rec->fields[5]->data );
 
 		if ( rec->fcount > 6 ) {
 			/* added in protocol 5.9 - flags & subtype */
@@ -1780,7 +1798,7 @@ static void mxit_parse_cmd_presence( str
 		if ( rec->fcount >= 7 )		/* flags field is included */
 			flags = atoi( rec->fields[6]->data );
 
-		mxit_update_buddy_presence( session, rec->fields[0]->data, mxit_parse_presence( rec->fields[1]->data ), atoi( rec->fields[2]->data ),
+		mxit_update_buddy_presence( session, rec->fields[0]->data, mxit_parse_presence( rec->fields[1]->data ), mxit_parse_mood( rec->fields[2]->data ),
 				rec->fields[3]->data, rec->fields[4]->data, flags );
 		mxit_update_buddy_avatar( session, rec->fields[0]->data, rec->fields[5]->data );
 	}
diff --git a/libpurple/protocols/mxit/roster.c b/libpurple/protocols/mxit/roster.c
--- a/libpurple/protocols/mxit/roster.c
+++ b/libpurple/protocols/mxit/roster.c
@@ -473,10 +473,6 @@ void mxit_update_buddy_presence( struct 
 	contact->mood = mood;
 	contact->capabilities = flags;
 
-	/* validate mood */
-	if ( ( contact->mood < MXIT_MOOD_NONE ) || ( contact->mood > MXIT_MOOD_STRESSED ) )
-		contact->mood = MXIT_MOOD_NONE;
-
 	g_strlcpy( contact->customMood, customMood, sizeof( contact->customMood ) );
 	// TODO: Download custom mood frame.
 



More information about the Commits mailing list