From ec29351181b9557c5490d2eed38505d22f9ce6bb Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Mon, 7 Dec 2009 22:11:40 +0000 Subject: Committing some >1y old change. This seems to fix a small leak in the MSN mail notification handler. --- protocols/msn/ns.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index fe48f96d..30a35e4e 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -662,8 +662,8 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int imcb_log( ic, "The server is going down for maintenance in %s minutes.", arg1 ); } - if( arg1 ) g_free( arg1 ); - if( mtype ) g_free( mtype ); + g_free( arg1 ); + g_free( mtype ); } else if( g_strncasecmp( ct, "text/x-msmsgsprofile", 20 ) == 0 ) { @@ -671,25 +671,30 @@ static int msn_ns_message( gpointer data, char *msg, int msglen, char **cmd, int } else if( g_strncasecmp( ct, "text/x-msmsgsinitialemailnotification", 37 ) == 0 ) { - char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); - char *folders = msn_findheader( body, "Folders-Unread:", blen ); - - if( inbox && folders && set_getbool( &ic->acc->set, "mail_notifications" ) ) + if( set_getbool( &ic->acc->set, "mail_notifications" ) ) { - imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); + char *inbox = msn_findheader( body, "Inbox-Unread:", blen ); + char *folders = msn_findheader( body, "Folders-Unread:", blen ); + + if( inbox && folders ) + imcb_log( ic, "INBOX contains %s new messages, plus %s messages in other folders.", inbox, folders ); + + g_free( inbox ); + g_free( folders ); } - - g_free( inbox ); - g_free( folders ); } else if( g_strncasecmp( ct, "text/x-msmsgsemailnotification", 30 ) == 0 ) { - char *from = msn_findheader( body, "From-Addr:", blen ); - char *fromname = msn_findheader( body, "From:", blen ); - - if( from && fromname && set_getbool( &ic->acc->set, "mail_notifications" ) ) + if( set_getbool( &ic->acc->set, "mail_notifications" ) ) { - imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); + char *from = msn_findheader( body, "From-Addr:", blen ); + char *fromname = msn_findheader( body, "From:", blen ); + + if( from && fromname ) + imcb_log( ic, "Received an e-mail message from %s <%s>.", fromname, from ); + + g_free( from ); + g_free( fromname ); } } else if( g_strncasecmp( ct, "text/x-msmsgsactivemailnotification", 35 ) == 0 ) -- cgit v1.2.3 From b051d39d99219852a1dc79f68ee301fc1fe16a5e Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sat, 6 Mar 2010 15:44:46 +0000 Subject: MSN module updated to deal with the new API. Not many changes since it doesn't currently support away messages anyway. This is more a bit of a cleanup. --- protocols/msn/ns.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index 30a35e4e..d05d8e0d 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -419,11 +419,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( !st ) { /* FIXME: Warn/Bomb about unknown away state? */ - st = msn_away_state_list; + st = msn_away_state_list + 1; } - imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | - ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); + imcb_buddy_status( ic, cmd[3], OPT_LOGGED_IN | + ( st != msn_away_state_list ? OPT_AWAY : 0 ), + st->name, NULL ); } else if( strcmp( cmd[0], "FLN" ) == 0 ) { @@ -448,11 +449,12 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) if( !st ) { /* FIXME: Warn/Bomb about unknown away state? */ - st = msn_away_state_list; + st = msn_away_state_list + 1; } - imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | - ( st->number ? OPT_AWAY : 0 ), st->name, NULL ); + imcb_buddy_status( ic, cmd[2], OPT_LOGGED_IN | + ( st != msn_away_state_list ? OPT_AWAY : 0 ), + st->name, NULL ); } else if( strcmp( cmd[0], "RNG" ) == 0 ) { -- cgit v1.2.3 From 21d48d977b35d35d0ad86b3ccd051dae0d1fe055 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Sun, 14 Mar 2010 20:19:10 +0000 Subject: Fix for bug #536: No longer fail on corrupted USR responses with certain Unicode characters in the friendly name. --- protocols/msn/ns.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'protocols/msn/ns.c') diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c index d05d8e0d..d78d753a 100644 --- a/protocols/msn/ns.c +++ b/protocols/msn/ns.c @@ -228,19 +228,26 @@ static int msn_ns_command( gpointer data, char **cmd, int num_parts ) return( 0 ); } } - else if( num_parts == 7 && strcmp( cmd[2], "OK" ) == 0 ) + else if( num_parts >= 7 && strcmp( cmd[2], "OK" ) == 0 ) { set_t *s; - http_decode( cmd[4] ); - - strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); - ic->displayname[sizeof(ic->displayname)-1] = 0; - - if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) + if( num_parts == 7 ) { - g_free( s->value ); - s->value = g_strdup( cmd[4] ); + http_decode( cmd[4] ); + + strncpy( ic->displayname, cmd[4], sizeof( ic->displayname ) ); + ic->displayname[sizeof(ic->displayname)-1] = 0; + + if( ( s = set_find( &ic->acc->set, "display_name" ) ) ) + { + g_free( s->value ); + s->value = g_strdup( cmd[4] ); + } + } + else + { + imcb_log( ic, "Warning: Friendly name in server response was corrupted" ); } imcb_log( ic, "Authenticated, getting buddy list" ); -- cgit v1.2.3