qulogic/pidgin

Fix for TALOS-CAN-0143
release-2.x.y
2016-06-03, Andrew Victor
b786e9814536
Parents 5e5e84e8a798
Children 530f70ef31e2
Fix for TALOS-CAN-0143
--- a/libpurple/protocols/mxit/protocol.c Sun May 15 05:41:39 2016 -0300
+++ b/libpurple/protocols/mxit/protocol.c Fri Jun 03 12:01:34 2016 -0500
@@ -1993,6 +1993,12 @@
* userid \1 contactType \1 value0 \1 value1 ... valueN
*/
+ /* ensure that record[0] contacts the minumum number of fields */
+ if ( records[0]->fcount < 4 ) {
+ purple_debug_error( MXIT_PLUGIN_ID, "Insufficient number of fields in suggest contacts response. fields=%i", records[0]->fcount );
+ return;
+ }
+
/* the type of results */
searchType = atoi( records[0]->fields[0]->data );
@@ -2002,11 +2008,24 @@
/* set the count for attributes */
count = atoi( records[0]->fields[3]->data );
+ /* ensure that record[0] contains the specified number of attributes */
+ if ( records[0]->fcount < ( 4 + count ) ) {
+ purple_debug_error( MXIT_PLUGIN_ID, "Insufficient number of fields in suggest contacts response. fields=%i attributes=%i", records[0]->fcount, count );
+ return;
+ }
+
for ( i = 1; i < rcount; i ++ ) {
struct record* rec = records[i];
struct MXitProfile* profile = g_new0( struct MXitProfile, 1 );
int j;
+ /* ensure that each result contains the specified number of attributes */
+ if ( rec->fcount != ( 2 + count ) ) {
+ purple_debug_error( MXIT_PLUGIN_ID, "Insufficient number of fields in suggest contacts response. fields=%i attributes=%i", rec->fcount, count );
+ g_free( profile );
+ continue;
+ }
+
g_strlcpy( profile->userid, rec->fields[0]->data, sizeof( profile->userid ) );
// TODO: ContactType - User or Service