2004-10-21 10:48:51 -04:00
|
|
|
$OpenBSD: patch-nick_c,v 1.2 2004/10/21 14:48:51 naddy Exp $
|
|
|
|
--- nick.c.orig Sun Jul 18 21:13:15 2004
|
|
|
|
+++ nick.c Fri Oct 15 14:31:10 2004
|
2004-06-20 12:27:49 -04:00
|
|
|
@@ -66,7 +66,7 @@ char *nick_get( irc_t *irc, char *handle
|
|
|
|
|
|
|
|
while( n && !*nick )
|
2004-10-21 10:48:51 -04:00
|
|
|
if( ( n->proto == proto ) && ( g_strcasecmp( n->handle, handle ) == 0 ) )
|
2004-06-20 12:27:49 -04:00
|
|
|
- strcpy( nick, n->nick );
|
|
|
|
+ strlcpy( nick, n->nick, sizeof(nick) );
|
|
|
|
else
|
|
|
|
n = n->next;
|
|
|
|
|
|
|
|
@@ -74,7 +74,7 @@ char *nick_get( irc_t *irc, char *handle
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
- g_snprintf( nick, MAX_NICK_LENGTH, "%s", handle );
|
|
|
|
+ g_snprintf( nick, sizeof(nick), "%s", handle );
|
|
|
|
if( ( s = strchr( nick, '@' ) ) )
|
|
|
|
while( *s )
|
|
|
|
*(s++) = 0;
|
|
|
|
@@ -83,7 +83,7 @@ char *nick_get( irc_t *irc, char *handle
|
|
|
|
use the realname instead. */
|
|
|
|
for( s = nick; *s && isdigit( *s ); s ++ );
|
|
|
|
if( !*s && realname && *realname )
|
|
|
|
- g_snprintf( nick, MAX_NICK_LENGTH, "%s", realname );
|
|
|
|
+ g_snprintf( nick, sizeof(nick), "%s", realname );
|
|
|
|
|
|
|
|
nick_strip( nick );
|
2004-10-21 10:48:51 -04:00
|
|
|
if (set_getint(irc, "lcnicks"))
|
|
|
|
@@ -120,7 +120,7 @@ char *nick_get( irc_t *irc, char *handle
|
2004-06-20 12:27:49 -04:00
|
|
|
"Good luck, and please don't forget to paste the lines up here "
|
|
|
|
"in #bitlbee on OFTC or in a mail to wilmer@gaast.net" );
|
|
|
|
|
|
|
|
- g_snprintf( nick, MAX_NICK_LENGTH + 1, "xx%x", rand() );
|
|
|
|
+ g_snprintf( nick, sizeof(nick), "xx%x", rand() );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2004-10-21 10:48:51 -04:00
|
|
|
@@ -244,8 +244,8 @@ int nick_cmp( char *a, char *b )
|
2004-06-20 12:27:49 -04:00
|
|
|
{
|
|
|
|
char aa[1024] = "", bb[1024] = "";
|
|
|
|
|
|
|
|
- strncpy( aa, a, sizeof( aa ) - 1 );
|
|
|
|
- strncpy( bb, b, sizeof( bb ) - 1 );
|
|
|
|
+ strlcpy( aa, a, sizeof( aa ) );
|
|
|
|
+ strlcpy( bb, b, sizeof( bb ) );
|
|
|
|
if( nick_lc( aa ) && nick_lc( bb ) )
|
|
|
|
{
|
|
|
|
return( strcmp( aa, bb ) );
|
2004-10-21 10:48:51 -04:00
|
|
|
@@ -259,10 +259,11 @@ int nick_cmp( char *a, char *b )
|
2004-06-20 12:27:49 -04:00
|
|
|
char *nick_dup( char *nick )
|
|
|
|
{
|
|
|
|
char *cp;
|
|
|
|
+ size_t cp_len = MAX_NICK_LENGTH +1;
|
|
|
|
|
|
|
|
- cp = bitlbee_alloc( MAX_NICK_LENGTH + 1 );
|
|
|
|
- memset( cp, 0, MAX_NICK_LENGTH + 1 );
|
|
|
|
- strncpy( cp, nick, MAX_NICK_LENGTH );
|
|
|
|
+ cp = bitlbee_alloc( cp_len );
|
|
|
|
+ memset( cp, 0, cp_len );
|
|
|
|
+ strlcpy( cp, nick, cp_len );
|
|
|
|
|
|
|
|
return( cp );
|
|
|
|
}
|