openbsd-ports/net/bitlbee/patches/patch-protocols_msn_ns_c
naddy a2c69a5b0d Update to 0.90.
Partial audit for string handling.

From: Andrew Dalgleish <openbsd@ajd.net.au>
2004-06-20 16:27:49 +00:00

33 lines
1.3 KiB
Plaintext

$OpenBSD: patch-protocols_msn_ns_c,v 1.1 2004/06/20 16:27:49 naddy Exp $
--- protocols/msn/ns.c.orig 2004-05-15 23:00:53.000000000 +1000
+++ protocols/msn/ns.c 2004-06-09 22:01:38.000000000 +1000
@@ -218,8 +218,7 @@ static int msn_ns_command( gpointer data
{
http_decode( cmd[4] );
- strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) );
- gc->displayname[sizeof(gc->displayname)-1] = 0;
+ strlcpy( gc->displayname, cmd[4], sizeof( gc->displayname ) );
set_login_progress( gc, 1, "Authenticated, getting buddy list" );
@@ -342,7 +341,7 @@ static int msn_ns_command( gpointer data
g_snprintf( buf, sizeof( buf ), "QRY %d %s %d\r\n", ++md->trId, QRY_NAME, 32 );
for( i = 0; i < 16; i ++ )
- g_snprintf( buf + strlen( buf ), 3, "%02x", digest[i] );
+ g_snprintf( buf + strlen( buf ), sizeof(buf)-strlen(buf), "%02x", digest[i] );
return( msn_write( gc, buf, strlen( buf ) ) );
}
@@ -502,8 +501,7 @@ static int msn_ns_command( gpointer data
if( g_strcasecmp( cmd[3], gc->username ) == 0 )
{
http_decode( cmd[4] );
- strncpy( gc->displayname, cmd[4], sizeof( gc->displayname ) );
- gc->displayname[sizeof(gc->displayname)-1] = 0;
+ strlcpy( gc->displayname, cmd[4], sizeof( gc->displayname ) );
}
else
{