openbsd-ports/net/bitlbee/patches/patch-protocols_msn_passport_c

79 lines
2.4 KiB
Plaintext

$OpenBSD: patch-protocols_msn_passport_c,v 1.3 2004/10/21 14:48:51 naddy Exp $
--- protocols/msn/passport.c.orig Wed Jul 7 23:38:16 2004
+++ protocols/msn/passport.c Thu Oct 14 15:43:34 2004
@@ -59,23 +59,30 @@ int passport_get_id( gpointer data, char
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( gpointe
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( g
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( g
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;