openbsd-ports/net/bitlbee/patches/patch-protocols_msn_passport_c
martynas 117ac1f407 update to bitlbee-1.0.4
ok simon@ and maintainer Andrew Dalgleish;  tested by Wiktor Izdebski
2007-11-19 11:44:32 +00:00

79 lines
2.4 KiB
Plaintext

$OpenBSD: patch-protocols_msn_passport_c,v 1.4 2007/11/19 11:44:33 martynas Exp $
--- protocols/msn/passport.c.orig Mon Aug 20 16:27:14 2007
+++ protocols/msn/passport.c Mon Nov 19 13:39:01 2007
@@ -59,23 +59,30 @@ int passport_get_id( gpointer data, char *username, ch
static char *passport_create_header( char *reply, char *email, char *pwd )
{
- char *buffer = g_new0( char, 2048 );
+ size_t buffer_len = 2048;
+ char *buffer = g_new0( char, buffer_len);
char *currenttoken;
char *email_enc, *pwd_enc;
- email_enc = g_new0( char, strlen( email ) * 3 + 1 );
- strcpy( email_enc, email );
- http_encode( email_enc );
+ {
+ size_t len = strlen( email ) * 3 + 1;
+ email_enc = g_new0( char, len );
+ strlcpy( email_enc, email, len );
+ http_encode( email_enc, len);
+ }
- pwd_enc = g_new0( char, strlen( pwd ) * 3 + 1 );
- strcpy( pwd_enc, pwd );
- http_encode( pwd_enc );
+ {
+ size_t len = strlen( pwd ) * 3 + 1;
+ pwd_enc = g_new0( char, len );
+ strlcpy( pwd_enc, pwd, len );
+ http_encode( pwd_enc, len );
+ }
currenttoken = strstr( reply, "lc=" );
if( currenttoken == NULL )
return( NULL );
- g_snprintf( buffer, 2048,
+ g_snprintf( buffer, buffer_len,
"Authorization: Passport1.4 OrgVerb=GET,"
"OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom,"
"sign-in=%s,pwd=%s,%s", email_enc, pwd_enc,
@@ -179,7 +186,7 @@ static int passport_get_id_from( gpointer data, gpoint
rep->func = func;
rep->redirects = 4;
- strncpy( server, url, 512 );
+ strlcpy( server, url, sizeof(server));
dummy = strchr( server, '/' );
if( dummy )
*dummy = 0;
@@ -220,14 +227,14 @@ static void passport_get_id_connected( gpointer data,
return;
}
- memset( buffer, 0, PPG_BUFFERSIZE + 1 );
+ memset( buffer, 0, sizeof(buffer));
- strncpy( server, rep->url, 512 );
+ strlcpy( server, rep->url, sizeof(server));
dummy = strchr( server, '/' );
if( dummy == NULL )
goto end;
- g_snprintf( buffer, PPG_BUFFERSIZE - 1, "GET %s HTTP/1.0\r\n"
+ g_snprintf( buffer, sizeof(buffer), "GET %s HTTP/1.0\r\n"
"%s\r\n\r\n", dummy, rep->header );
ssl_write( ssl, buffer, strlen( buffer ) );
@@ -265,7 +272,7 @@ static void passport_get_id_connected( gpointer data,
g_free( rep->url );
rep->url = g_strdup( dummy );
- strncpy( server, dummy, sizeof( server ) - 1 );
+ strlcpy( server, dummy, sizeof( server ));
dummy = strchr( server, '/' );
if( dummy ) *dummy = 0;