53e6084bfe
from Martynas Venckus <martynas at altroot dot org>
83 lines
3.2 KiB
Plaintext
83 lines
3.2 KiB
Plaintext
$OpenBSD: patch-commands_c,v 1.4 2007/01/14 21:53:01 simon Exp $
|
|
--- commands.c.orig Sat Jun 24 17:00:43 2006
|
|
+++ commands.c Fri Dec 15 21:20:07 2006
|
|
@@ -63,8 +63,8 @@ int cmd_help( irc_t *irc, char **cmd )
|
|
memset( param, 0, sizeof(param) );
|
|
for ( i = 1; (cmd[i] != NULL && ( strlen(param) < (sizeof(param)-1) ) ); i++ ) {
|
|
if ( i != 1 ) // prepend space except for the first parameter
|
|
- strcat(param, " ");
|
|
- strncat( param, cmd[i], sizeof(param) - strlen(param) - 1 );
|
|
+ strlcat(param, " ", sizeof(param));
|
|
+ strlcat( param, cmd[i], sizeof(param));
|
|
}
|
|
|
|
s = help_get( &(global.help), param );
|
|
@@ -118,10 +118,10 @@ int cmd_register( irc_t *irc, char **cmd
|
|
return( 0 );
|
|
}
|
|
|
|
- g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
|
|
+ g_snprintf( path, sizeof(path), "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
|
|
checkie = access( path, F_OK );
|
|
|
|
- g_snprintf( path, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
|
|
+ g_snprintf( path, sizeof(path), "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
|
|
checkie += access( path, F_OK );
|
|
|
|
if( checkie == -2 )
|
|
@@ -143,7 +143,7 @@ int cmd_drop( irc_t *irc, char **cmd )
|
|
char s[512];
|
|
FILE *fp;
|
|
|
|
- g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
|
|
+ g_snprintf( s, sizeof(s), "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
|
|
fp = fopen( s, "r" );
|
|
if( !fp )
|
|
{
|
|
@@ -151,6 +151,7 @@ int cmd_drop( irc_t *irc, char **cmd )
|
|
return( 0 );
|
|
}
|
|
|
|
+ COMPILE_TIME_ASSERT(32 < sizeof(s));
|
|
fscanf( fp, "%32[^\n]s", s );
|
|
fclose( fp );
|
|
if( setpass( irc, cmd[1], s ) < 0 )
|
|
@@ -159,10 +160,10 @@ int cmd_drop( irc_t *irc, char **cmd )
|
|
return( 0 );
|
|
}
|
|
|
|
- g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
|
|
+ g_snprintf( s, sizeof(s), "%s%s%s", global.conf->configdir, irc->nick, ".accounts" );
|
|
unlink( s );
|
|
|
|
- g_snprintf( s, 511, "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
|
|
+ g_snprintf( s, sizeof(s), "%s%s%s", global.conf->configdir, irc->nick, ".nicks" );
|
|
unlink( s );
|
|
|
|
setpassnc( irc, NULL );
|
|
@@ -718,21 +719,21 @@ int cmd_blist( irc_t *irc, char **cmd )
|
|
|
|
if( online == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && u->online && !u->away )
|
|
{
|
|
- g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
|
|
+ g_snprintf( s, sizeof(s), "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
|
|
irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, "Online" );
|
|
n_online ++;
|
|
}
|
|
|
|
if( away == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && u->online && u->away )
|
|
{
|
|
- g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
|
|
+ g_snprintf( s, sizeof(s), "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
|
|
irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, u->away );
|
|
n_away ++;
|
|
}
|
|
|
|
if( offline == 1 ) for( u = irc->users; u; u = u->next ) if( u->gc && !u->online )
|
|
{
|
|
- g_snprintf( s, 63, "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
|
|
+ g_snprintf( s, sizeof(s), "%s@%s (%s)", u->user, u->host, proto_name[u->gc->user->protocol] );
|
|
irc_usermsg( irc, "%-16.16s %-40.40s %s", u->nick, s, "Offline" );
|
|
n_offline ++;
|
|
}
|