- replaced all strncpy()'s and strncat()'s with strlcpy() and strlcat().

This commit is contained in:
Alexander Barton 2002-12-26 16:25:43 +00:00
parent 4f6f84e7e1
commit 0ced4181b0
7 changed files with 55 additions and 109 deletions

View File

@ -17,7 +17,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: channel.c,v 1.39 2002/12/25 13:22:43 alex Exp $"; static char UNUSED id[] = "$Id: channel.c,v 1.40 2002/12/26 16:25:43 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -629,8 +629,7 @@ Channel_SetTopic( CHANNEL *Chan, CHAR *Topic )
assert( Chan != NULL ); assert( Chan != NULL );
assert( Topic != NULL ); assert( Topic != NULL );
strncpy( Chan->topic, Topic, CHANNEL_TOPIC_LEN - 1 ); strlcpy( Chan->topic, Topic, sizeof( Chan->topic ));
Chan->topic[CHANNEL_TOPIC_LEN - 1] = '\0';
} /* Channel_SetTopic */ } /* Channel_SetTopic */
@ -640,8 +639,7 @@ Channel_SetModes( CHANNEL *Chan, CHAR *Modes )
assert( Chan != NULL ); assert( Chan != NULL );
assert( Modes != NULL ); assert( Modes != NULL );
strncpy( Chan->modes, Modes, CHANNEL_MODE_LEN - 1 ); strlcpy( Chan->modes, Modes, sizeof( Chan->modes ));
Chan->topic[CHANNEL_MODE_LEN - 1] = '\0';
} /* Channel_SetModes */ } /* Channel_SetModes */
@ -651,8 +649,7 @@ Channel_SetKey( CHANNEL *Chan, CHAR *Key )
assert( Chan != NULL ); assert( Chan != NULL );
assert( Key != NULL ); assert( Key != NULL );
strncpy( Chan->key, Key, CLIENT_PASS_LEN - 1 ); strlcpy( Chan->key, Key, sizeof( Chan->key ));
Chan->key[CLIENT_PASS_LEN - 1] = '\0';
Log( LOG_DEBUG, "Channel %s: Key is now \"%s\".", Chan->name, Chan->key ); Log( LOG_DEBUG, "Channel %s: Key is now \"%s\".", Chan->name, Chan->key );
} /* Channel_SetKey */ } /* Channel_SetKey */
@ -710,7 +707,7 @@ Channel_Create( CHAR *Name )
return NULL; return NULL;
} }
c->next = NULL; c->next = NULL;
strncpy( c->name, Name, CHANNEL_NAME_LEN - 1 ); strlcpy( c->name, Name, sizeof( c->name ));
c->name[CHANNEL_NAME_LEN - 1] = '\0'; c->name[CHANNEL_NAME_LEN - 1] = '\0';
strcpy( c->modes, "" ); strcpy( c->modes, "" );
strcpy( c->topic, "" ); strcpy( c->topic, "" );

View File

@ -17,7 +17,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: client.c,v 1.67 2002/12/22 23:29:09 alex Exp $"; static char UNUSED id[] = "$Id: client.c,v 1.68 2002/12/26 16:25:43 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -300,8 +300,7 @@ Client_SetHostname( CLIENT *Client, CHAR *Hostname )
assert( Client != NULL ); assert( Client != NULL );
assert( Hostname != NULL ); assert( Hostname != NULL );
strncpy( Client->host, Hostname, CLIENT_HOST_LEN - 1 ); strlcpy( Client->host, Hostname, sizeof( Client->host ));
Client->host[CLIENT_HOST_LEN - 1] = '\0';
} /* Client_SetHostname */ } /* Client_SetHostname */
@ -313,8 +312,7 @@ Client_SetID( CLIENT *Client, CHAR *ID )
assert( Client != NULL ); assert( Client != NULL );
assert( ID != NULL ); assert( ID != NULL );
strncpy( Client->id, ID, CLIENT_ID_LEN - 1 ); strlcpy( Client->id, ID, sizeof( Client->id ));
Client->id[CLIENT_ID_LEN - 1] = '\0';
/* Hash */ /* Hash */
Client->hash = Hash( Client->id ); Client->hash = Hash( Client->id );
@ -329,13 +327,12 @@ Client_SetUser( CLIENT *Client, CHAR *User, BOOLEAN Idented )
assert( Client != NULL ); assert( Client != NULL );
assert( User != NULL ); assert( User != NULL );
if( Idented ) strncpy( Client->user, User, CLIENT_USER_LEN - 1 ); if( Idented ) strlcpy( Client->user, User, sizeof( Client->user ));
else else
{ {
Client->user[0] = '~'; Client->user[0] = '~';
strncpy( Client->user + 1, User, CLIENT_USER_LEN - 2 ); strlcpy( Client->user + 1, User, sizeof( Client->user ) - 1 );
} }
Client->user[CLIENT_USER_LEN - 1] = '\0';
} /* Client_SetUser */ } /* Client_SetUser */
@ -347,8 +344,7 @@ Client_SetInfo( CLIENT *Client, CHAR *Info )
assert( Client != NULL ); assert( Client != NULL );
assert( Info != NULL ); assert( Info != NULL );
strncpy( Client->info, Info, CLIENT_INFO_LEN - 1 ); strlcpy( Client->info, Info, sizeof( Client->info ));
Client->info[CLIENT_INFO_LEN - 1] = '\0';
} /* Client_SetInfo */ } /* Client_SetInfo */
@ -360,8 +356,7 @@ Client_SetModes( CLIENT *Client, CHAR *Modes )
assert( Client != NULL ); assert( Client != NULL );
assert( Modes != NULL ); assert( Modes != NULL );
strncpy( Client->modes, Modes, CLIENT_MODE_LEN - 1 ); strlcpy( Client->modes, Modes, sizeof( Client->modes ));
Client->modes[CLIENT_MODE_LEN - 1] = '\0';
} /* Client_SetModes */ } /* Client_SetModes */
@ -373,8 +368,7 @@ Client_SetFlags( CLIENT *Client, CHAR *Flags )
assert( Client != NULL ); assert( Client != NULL );
assert( Flags != NULL ); assert( Flags != NULL );
strncpy( Client->flags, Flags, CLIENT_FLAGS_LEN - 1 ); strlcpy( Client->flags, Flags, sizeof( Client->flags ));
Client->flags[CLIENT_FLAGS_LEN - 1] = '\0';
} /* Client_SetFlags */ } /* Client_SetFlags */
@ -386,8 +380,7 @@ Client_SetPassword( CLIENT *Client, CHAR *Pwd )
assert( Client != NULL ); assert( Client != NULL );
assert( Pwd != NULL ); assert( Pwd != NULL );
strncpy( Client->pwd, Pwd, CLIENT_PASS_LEN - 1 ); strlcpy( Client->pwd, Pwd, sizeof( Client->pwd ));
Client->pwd[CLIENT_PASS_LEN - 1] = '\0';
} /* Client_SetPassword */ } /* Client_SetPassword */
@ -401,8 +394,7 @@ Client_SetAway( CLIENT *Client, CHAR *Txt )
if( Txt ) if( Txt )
{ {
/* Client AWAY setzen */ /* Client AWAY setzen */
strncpy( Client->away, Txt, CLIENT_AWAY_LEN - 1 ); strlcpy( Client->away, Txt, sizeof( Client->away ));
Client->away[CLIENT_AWAY_LEN - 1] = '\0';
Client_ModeAdd( Client, 'a' ); Client_ModeAdd( Client, 'a' );
Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt ); Log( LOG_DEBUG, "User \"%s\" is away: %s", Client_Mask( Client ), Txt );
} }
@ -539,8 +531,7 @@ Client_Search( CHAR *Nick )
assert( Nick != NULL ); assert( Nick != NULL );
/* Nick kopieren und ggf. Host-Mask abschneiden */ /* Nick kopieren und ggf. Host-Mask abschneiden */
strncpy( search_id, Nick, CLIENT_ID_LEN - 1 ); strlcpy( search_id, Nick, sizeof( search_id ));
search_id[CLIENT_ID_LEN - 1] = '\0';
ptr = strchr( search_id, '!' ); ptr = strchr( search_id, '!' );
if( ptr ) *ptr = '\0'; if( ptr ) *ptr = '\0';

View File

@ -14,7 +14,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: conf.c,v 1.48 2002/12/26 13:17:56 alex Exp $"; static char UNUSED id[] = "$Id: conf.c,v 1.49 2002/12/26 16:25:43 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -330,49 +330,37 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
if( strcasecmp( Var, "Name" ) == 0 ) if( strcasecmp( Var, "Name" ) == 0 )
{ {
/* Server name */ /* Server name */
strncpy( Conf_ServerName, Arg, CLIENT_ID_LEN - 1 ); if( strlcpy( Conf_ServerName, Arg, sizeof( Conf_ServerName )) >= sizeof( Conf_ServerName )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
Conf_ServerName[CLIENT_ID_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_ID_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "Info" ) == 0 ) if( strcasecmp( Var, "Info" ) == 0 )
{ {
/* Info text of server */ /* Info text of server */
strncpy( Conf_ServerInfo, Arg, CLIENT_INFO_LEN - 1 ); if( strlcpy( Conf_ServerInfo, Arg, sizeof( Conf_ServerInfo )) >= sizeof( Conf_ServerInfo )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Info\" too long!", NGIRCd_ConfFile, Line );
Conf_ServerInfo[CLIENT_INFO_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_INFO_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Info\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "Password" ) == 0 ) if( strcasecmp( Var, "Password" ) == 0 )
{ {
/* Global server password */ /* Global server password */
strncpy( Conf_ServerPwd, Arg, CLIENT_PASS_LEN - 1 ); if( strlcpy( Conf_ServerPwd, Arg, sizeof( Conf_ServerPwd )) >= sizeof( Conf_ServerPwd )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Password\" too long!", NGIRCd_ConfFile, Line );
Conf_ServerPwd[CLIENT_PASS_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_PASS_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Password\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "AdminInfo1" ) == 0 ) if( strcasecmp( Var, "AdminInfo1" ) == 0 )
{ {
/* Administrative info #1 */ /* Administrative info #1 */
strncpy( Conf_ServerAdmin1, Arg, CLIENT_INFO_LEN - 1 ); if( strlcpy( Conf_ServerAdmin1, Arg, sizeof( Conf_ServerAdmin1 )) >= sizeof( Conf_ServerAdmin1 )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminInfo1\" too long!", NGIRCd_ConfFile, Line );
Conf_ServerAdmin1[CLIENT_INFO_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_INFO_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminInfo1\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "AdminInfo2" ) == 0 ) if( strcasecmp( Var, "AdminInfo2" ) == 0 )
{ {
/* Administrative info #2 */ /* Administrative info #2 */
strncpy( Conf_ServerAdmin2, Arg, CLIENT_INFO_LEN - 1 ); if( strlcpy( Conf_ServerAdmin2, Arg, sizeof( Conf_ServerAdmin2 )) >= sizeof( Conf_ServerAdmin2 )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminInfo2\" too long!", NGIRCd_ConfFile, Line );
Conf_ServerAdmin2[CLIENT_INFO_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_INFO_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminInfo2\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "AdminEMail" ) == 0 ) if( strcasecmp( Var, "AdminEMail" ) == 0 )
{ {
/* Administrative email contact */ /* Administrative email contact */
strncpy( Conf_ServerAdminMail, Arg, CLIENT_INFO_LEN - 1 ); if( strlcpy( Conf_ServerAdminMail, Arg, sizeof( Conf_ServerAdminMail )) >= sizeof( Conf_ServerAdminMail )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminEMail\" too long!", NGIRCd_ConfFile, Line );
Conf_ServerAdminMail[CLIENT_INFO_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_INFO_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"AdminEMail\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "Ports" ) == 0 ) if( strcasecmp( Var, "Ports" ) == 0 )
@ -397,9 +385,7 @@ Handle_GLOBAL( INT Line, CHAR *Var, CHAR *Arg )
if( strcasecmp( Var, "MotdFile" ) == 0 ) if( strcasecmp( Var, "MotdFile" ) == 0 )
{ {
/* "Message of the day" (MOTD) file */ /* "Message of the day" (MOTD) file */
strncpy( Conf_MotdFile, Arg, FNAME_LEN - 1 ); if( strlcpy( Conf_MotdFile, Arg, sizeof( Conf_MotdFile )) >= sizeof( Conf_MotdFile )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MotdFile\" too long!", NGIRCd_ConfFile, Line );
Conf_MotdFile[FNAME_LEN - 1] = '\0';
if( strlen( Arg ) > FNAME_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MotdFile\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "ServerUID" ) == 0 ) if( strcasecmp( Var, "ServerUID" ) == 0 )
@ -510,17 +496,13 @@ Handle_OPERATOR( INT Line, CHAR *Var, CHAR *Arg )
if( strcasecmp( Var, "Name" ) == 0 ) if( strcasecmp( Var, "Name" ) == 0 )
{ {
/* Name of IRC operator */ /* Name of IRC operator */
strncpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, CLIENT_PASS_LEN - 1 ); if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].name, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
Conf_Oper[Conf_Oper_Count - 1].name[CLIENT_PASS_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_PASS_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "Password" ) == 0 ) if( strcasecmp( Var, "Password" ) == 0 )
{ {
/* Password of IRC operator */ /* Password of IRC operator */
strncpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, CLIENT_PASS_LEN - 1 ); if( strlcpy( Conf_Oper[Conf_Oper_Count - 1].pwd, Arg, sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) >= sizeof( Conf_Oper[Conf_Oper_Count - 1].pwd )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Password\" too long!", NGIRCd_ConfFile, Line );
Conf_Oper[Conf_Oper_Count - 1].pwd[CLIENT_PASS_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_PASS_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Password\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
@ -540,33 +522,25 @@ Handle_SERVER( INT Line, CHAR *Var, CHAR *Arg )
if( strcasecmp( Var, "Host" ) == 0 ) if( strcasecmp( Var, "Host" ) == 0 )
{ {
/* Hostname of the server */ /* Hostname of the server */
strncpy( Conf_Server[Conf_Server_Count - 1].host, Arg, HOST_LEN - 1 ); if( strlcpy( Conf_Server[Conf_Server_Count - 1].host, Arg, sizeof( Conf_Server[Conf_Server_Count - 1].host )) >= sizeof( Conf_Server[Conf_Server_Count - 1].host )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Host\" too long!", NGIRCd_ConfFile, Line );
Conf_Server[Conf_Server_Count - 1].host[HOST_LEN - 1] = '\0';
if( strlen( Arg ) > HOST_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Host\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "Name" ) == 0 ) if( strcasecmp( Var, "Name" ) == 0 )
{ {
/* Name of the server ("Nick"/"ID") */ /* Name of the server ("Nick"/"ID") */
strncpy( Conf_Server[Conf_Server_Count - 1].name, Arg, CLIENT_ID_LEN - 1 ); if( strlcpy( Conf_Server[Conf_Server_Count - 1].name, Arg, sizeof( Conf_Server[Conf_Server_Count - 1].name )) >= sizeof( Conf_Server[Conf_Server_Count - 1].name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
Conf_Server[Conf_Server_Count - 1].name[CLIENT_ID_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_ID_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "MyPassword" ) == 0 ) if( strcasecmp( Var, "MyPassword" ) == 0 )
{ {
/* Password of this server which is sent to the peer */ /* Password of this server which is sent to the peer */
strncpy( Conf_Server[Conf_Server_Count - 1].pwd_in, Arg, CLIENT_PASS_LEN - 1 ); if( strlcpy( Conf_Server[Conf_Server_Count - 1].pwd_in, Arg, sizeof( Conf_Server[Conf_Server_Count - 1].pwd_in )) >= sizeof( Conf_Server[Conf_Server_Count - 1].pwd_in )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MyPassword\" too long!", NGIRCd_ConfFile, Line );
Conf_Server[Conf_Server_Count - 1].pwd_in[CLIENT_PASS_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_PASS_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"MyPassword\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "PeerPassword" ) == 0 ) if( strcasecmp( Var, "PeerPassword" ) == 0 )
{ {
/* Passwort of the peer which must be received */ /* Passwort of the peer which must be received */
strncpy( Conf_Server[Conf_Server_Count - 1].pwd_out, Arg, CLIENT_PASS_LEN - 1 ); if( strlcpy( Conf_Server[Conf_Server_Count - 1].pwd_out, Arg, sizeof( Conf_Server[Conf_Server_Count - 1].pwd_out )) >= sizeof( Conf_Server[Conf_Server_Count - 1].pwd_out )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"PeerPassword\" too long!", NGIRCd_ConfFile, Line );
Conf_Server[Conf_Server_Count - 1].pwd_out[CLIENT_PASS_LEN - 1] = '\0';
if( strlen( Arg ) > CLIENT_PASS_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"PeerPassword\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "Port" ) == 0 ) if( strcasecmp( Var, "Port" ) == 0 )
@ -602,25 +576,19 @@ Handle_CHANNEL( INT Line, CHAR *Var, CHAR *Arg )
if( strcasecmp( Var, "Name" ) == 0 ) if( strcasecmp( Var, "Name" ) == 0 )
{ {
/* Name of the channel */ /* Name of the channel */
strncpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, CHANNEL_NAME_LEN - 1 ); if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].name, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].name )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].name )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
Conf_Channel[Conf_Channel_Count - 1].name[CHANNEL_NAME_LEN - 1] = '\0';
if( strlen( Arg ) > CHANNEL_NAME_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Name\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "Modes" ) == 0 ) if( strcasecmp( Var, "Modes" ) == 0 )
{ {
/* Initial modes */ /* Initial modes */
strncpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, CHANNEL_MODE_LEN - 1 ); if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].modes, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].modes )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].modes )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Modes\" too long!", NGIRCd_ConfFile, Line );
Conf_Channel[Conf_Channel_Count - 1].modes[CHANNEL_MODE_LEN - 1] = '\0';
if( strlen( Arg ) > CHANNEL_MODE_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Modes\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }
if( strcasecmp( Var, "Topic" ) == 0 ) if( strcasecmp( Var, "Topic" ) == 0 )
{ {
/* Initial topic */ /* Initial topic */
strncpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, CHANNEL_TOPIC_LEN - 1 ); if( strlcpy( Conf_Channel[Conf_Channel_Count - 1].topic, Arg, sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) >= sizeof( Conf_Channel[Conf_Channel_Count - 1].topic )) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Topic\" too long!", NGIRCd_ConfFile, Line );
Conf_Channel[Conf_Channel_Count - 1].topic[CHANNEL_TOPIC_LEN - 1] = '\0';
if( strlen( Arg ) > CHANNEL_TOPIC_LEN - 1 ) Config_Error( LOG_WARNING, "%s, line %d: Value of \"Topic\" too long!", NGIRCd_ConfFile, Line );
return; return;
} }

View File

@ -14,7 +14,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: hash.c,v 1.8 2002/12/26 13:16:54 alex Exp $"; static char UNUSED id[] = "$Id: hash.c,v 1.9 2002/12/26 16:25:43 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -38,9 +38,7 @@ Hash( CHAR *String )
CHAR buffer[LINE_LEN]; CHAR buffer[LINE_LEN];
strncpy( buffer, String, LINE_LEN - 1 ); strlcpy( buffer, String, sizeof( buffer ));
buffer[LINE_LEN - 1] = '\0';
return jenkins_hash( (UINT8 *)ngt_LowerStr( buffer ), strlen( buffer ), 42 ); return jenkins_hash( (UINT8 *)ngt_LowerStr( buffer ), strlen( buffer ), 42 );
} /* Hash */ } /* Hash */

View File

@ -14,7 +14,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: irc-server.c,v 1.24 2002/12/12 12:24:18 alex Exp $"; static char UNUSED id[] = "$Id: irc-server.c,v 1.25 2002/12/26 16:25:43 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -284,8 +284,7 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
/* Falsche Anzahl Parameter? */ /* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
strncpy( str, Req->argv[1], COMMAND_LEN - 1 ); strlcpy( str, Req->argv[1], sizeof( str ));
str[COMMAND_LEN - 1] = '\0';
channame = Req->argv[0]; channame = Req->argv[0];
ptr = strtok( str, "," ); ptr = strtok( str, "," );

View File

@ -14,7 +14,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: lists.c,v 1.10 2002/12/12 12:24:18 alex Exp $"; static char UNUSED id[] = "$Id: lists.c,v 1.11 2002/12/26 16:25:43 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -331,19 +331,17 @@ Lists_MakeMask( CHAR *Pattern )
if(( ! at ) && ( ! excl )) if(( ! at ) && ( ! excl ))
{ {
/* weder ! noch @Êvorhanden: als Nick annehmen */ /* weder ! noch @ vorhanden: als Nick annehmen */
strncpy( TheMask, Pattern, MASK_LEN - 5 ); strlcpy( TheMask, Pattern, sizeof( TheMask ) - 5 );
TheMask[MASK_LEN - 5] = '\0'; strlcat( TheMask, "!*@*", sizeof( TheMask ));
strcat( TheMask, "!*@*" );
return TheMask; return TheMask;
} }
if(( ! at ) && ( excl )) if(( ! at ) && ( excl ))
{ {
/* Domain fehlt */ /* Domain fehlt */
strncpy( TheMask, Pattern, MASK_LEN - 3 ); strlcpy( TheMask, Pattern, sizeof( TheMask ) - 3 );
TheMask[MASK_LEN - 3] = '\0'; strlcat( TheMask, "@*", sizeof( TheMask ));
strcat( TheMask, "@*" );
return TheMask; return TheMask;
} }
@ -351,17 +349,14 @@ Lists_MakeMask( CHAR *Pattern )
{ {
/* User fehlt */ /* User fehlt */
*at = '\0'; at++; *at = '\0'; at++;
strncpy( TheMask, Pattern, MASK_LEN - 4 ); strlcpy( TheMask, Pattern, sizeof( TheMask ) - strlen( at ) - 4 );
TheMask[MASK_LEN - 4] = '\0'; strlcat( TheMask, "!*@", sizeof( TheMask ));
strcat( TheMask, "!*@" ); strlcat( TheMask, at, sizeof( TheMask ));
strncat( TheMask, at, strlen( TheMask ) - MASK_LEN - 1 );
TheMask[MASK_LEN - 1] = '\0';
return TheMask; return TheMask;
} }
/* alle Teile vorhanden */ /* alle Teile vorhanden */
strncpy( TheMask, Pattern, MASK_LEN - 1 ); strlcpy( TheMask, Pattern, sizeof( TheMask ));
TheMask[MASK_LEN - 1] = '\0';
return TheMask; return TheMask;
} /* Lists_MakeMask */ } /* Lists_MakeMask */
@ -382,7 +377,7 @@ New_C2C( CHAR *Mask, CHANNEL *Chan, BOOLEAN OnlyOnce )
return NULL; return NULL;
} }
strncpy( c2c->mask, Mask, MASK_LEN ); strlcpy( c2c->mask, Mask, sizeof( c2c->mask ));
c2c->channel = Chan; c2c->channel = Chan;
c2c->onlyonce = OnlyOnce; c2c->onlyonce = OnlyOnce;

View File

@ -14,7 +14,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: ngircd.c,v 1.66 2002/12/26 13:17:57 alex Exp $"; static char UNUSED id[] = "$Id: ngircd.c,v 1.67 2002/12/26 16:25:43 alex Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -88,11 +88,10 @@ main( int argc, const char *argv[] )
{ {
if( i + 1 < argc ) if( i + 1 < argc )
{ {
/* Ok, danach kommt noch ein Parameter */ /* Ok, there's an parameter left */
strncpy( NGIRCd_ConfFile, argv[i + 1], FNAME_LEN - 1 ); strlcpy( NGIRCd_ConfFile, argv[i + 1], sizeof( NGIRCd_ConfFile ));
NGIRCd_ConfFile[FNAME_LEN - 1] = '\0';
/* zum uebernaechsten Parameter */ /* next parameter */
i++; ok = TRUE; i++; ok = TRUE;
} }
} }
@ -155,11 +154,10 @@ main( int argc, const char *argv[] )
{ {
if(( ! argv[i][n + 1] ) && ( i + 1 < argc )) if(( ! argv[i][n + 1] ) && ( i + 1 < argc ))
{ {
/* Ok, danach kommt ein Leerzeichen */ /* Ok, next character is a blank */
strncpy( NGIRCd_ConfFile, argv[i + 1], FNAME_LEN - 1 ); strlcpy( NGIRCd_ConfFile, argv[i + 1], sizeof( NGIRCd_ConfFile ));
NGIRCd_ConfFile[FNAME_LEN - 1] = '\0';
/* zum uebernaechsten Parameter */ /* go to the following parameter */
i++; n = (LONG)strlen( argv[i] ); i++; n = (LONG)strlen( argv[i] );
ok = TRUE; ok = TRUE;
} }