diff options
Diffstat (limited to 'protocols/msn/passport.c')
| -rw-r--r-- | protocols/msn/passport.c | 32 | 
1 files changed, 25 insertions, 7 deletions
| diff --git a/protocols/msn/passport.c b/protocols/msn/passport.c index 34703432..dd1d9b6f 100644 --- a/protocols/msn/passport.c +++ b/protocols/msn/passport.c @@ -68,8 +68,7 @@ static int passport_get_id_real( gpointer func, gpointer data, char *header )  		return( 0 );  	} -	reqs = g_malloc( strlen( header ) + strlen( dummy ) + 128 ); -	sprintf( reqs, "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header ); +	reqs = g_strdup_printf( "GET %s HTTP/1.0\r\n%s\r\n\r\n", dummy, header );  	*dummy = 0;  	req = http_dorequest( server, 443, 1, reqs, passport_get_id_ready, rep ); @@ -87,13 +86,13 @@ static void passport_get_id_ready( struct http_request *req )  {  	struct passport_reply *rep = req->data; -	if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers ) +	if( !g_slist_find( msn_connections, rep->data ) )  	{  		destroy_reply( rep );  		return;  	} -	if( req->status_code == 200 ) +	if( req->finished && req->reply_headers && req->status_code == 200 )  	{  		char *dummy; @@ -108,6 +107,15 @@ static void passport_get_id_ready( struct http_request *req )  			rep->result = g_strdup( dummy );  		} +		else +		{ +			rep->error_string = g_strdup( "Could not parse Passport server response" ); +		} +	} +	else +	{ +		rep->error_string = g_strdup_printf( "HTTP error: %s", +		                      req->status_string ? req->status_string : "Unknown error" );  	}  	rep->func( rep ); @@ -144,7 +152,6 @@ static char *passport_create_header( char *cookie, char *email, char *pwd )  	return( buffer );  } -#define PPR_REQUEST "GET /rdr/pprdr.asp HTTP/1.0\r\n\r\n"  static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header )  {  	struct passport_reply *rep = g_new0( struct passport_reply, 1 ); @@ -154,7 +161,7 @@ static int passport_retrieve_dalogin( gpointer func, gpointer data, char *header  	rep->func = func;  	rep->header = header; -	req = http_dorequest( "nexus.passport.com", 443, 1, PPR_REQUEST, passport_retrieve_dalogin_ready, rep ); +	req = http_dorequest_url( "https://nexus.passport.com/rdr/pprdr.asp", passport_retrieve_dalogin_ready, rep );  	if( !req )  		destroy_reply( rep ); @@ -168,16 +175,26 @@ static void passport_retrieve_dalogin_ready( struct http_request *req )  	char *dalogin;  	char *urlend; -	if( !g_slist_find( msn_connections, rep->data ) || !req->finished || !req->reply_headers ) +	if( !g_slist_find( msn_connections, rep->data ) )  	{  		destroy_reply( rep );  		return;  	} +	if( !req->finished || !req->reply_headers || req->status_code != 200 ) +	{ +		rep->error_string = g_strdup_printf( "HTTP error while fetching DALogin: %s", +		                        req->status_string ? req->status_string : "Unknown error" ); +		goto failure; +	} +	  	dalogin = strstr( req->reply_headers, "DALogin=" );	  	if( !dalogin ) +	{ +		rep->error_string = g_strdup( "Parse error while fetching DALogin" );  		goto failure; +	}  	dalogin += strlen( "DALogin=" );  	urlend = strchr( dalogin, ',' ); @@ -207,5 +224,6 @@ static void destroy_reply( struct passport_reply *rep )  {  	g_free( rep->result );  	g_free( rep->header ); +	g_free( rep->error_string );  	g_free( rep );  } | 
