1
0
mirror of https://github.com/osmarks/ngircd.git synced 2024-12-12 09:50:29 +00:00

Client_IsValidNick: no need to strcpy.

This commit is contained in:
Florian Westphal 2006-10-06 19:57:56 +00:00
parent 4108e16be6
commit 27c96632f1
2 changed files with 9 additions and 12 deletions

View File

@ -17,7 +17,7 @@
#include "portab.h" #include "portab.h"
static char UNUSED id[] = "$Id: client.c,v 1.91 2006/04/23 10:37:27 fw Exp $"; static char UNUSED id[] = "$Id: client.c,v 1.92 2006/10/06 19:57:56 fw Exp $";
#include "imp.h" #include "imp.h"
#include <assert.h> #include <assert.h>
@ -979,16 +979,13 @@ Client_MyMaxUserCount( void )
GLOBAL bool GLOBAL bool
Client_IsValidNick( char *Nick ) Client_IsValidNick( const char *Nick )
{ {
/* Ist der Nick gueltig? */ const char *ptr;
static const char goodchars[] = ";0123456789-";
char *ptr, goodchars[20];
assert( Nick != NULL ); assert( Nick != NULL );
strcpy( goodchars, ";0123456789-" );
if( Nick[0] == '#' ) return false; if( Nick[0] == '#' ) return false;
if( strchr( goodchars, Nick[0] )) return false; if( strchr( goodchars, Nick[0] )) return false;
if( strlen( Nick ) >= CLIENT_NICK_LEN ) return false; if( strlen( Nick ) >= CLIENT_NICK_LEN ) return false;
@ -996,8 +993,8 @@ Client_IsValidNick( char *Nick )
ptr = Nick; ptr = Nick;
while( *ptr ) while( *ptr )
{ {
if(( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return false; if (( *ptr < 'A' ) && ( ! strchr( goodchars, *ptr ))) return false;
if(( *ptr > '}' ) && ( ! strchr( goodchars, *ptr ))) return false; if ( *ptr > '}' ) return false;
ptr++; ptr++;
} }

View File

@ -8,7 +8,7 @@
* (at your option) any later version. * (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information. * Please read the file COPYING, README and AUTHORS for more information.
* *
* $Id: client.h,v 1.43 2006/10/01 19:05:02 alex Exp $ * $Id: client.h,v 1.44 2006/10/06 19:57:56 fw Exp $
* *
* Client management (header) * Client management (header)
*/ */
@ -145,7 +145,7 @@ GLOBAL long Client_MyServerCount PARAMS(( void ));
GLOBAL long Client_MaxUserCount PARAMS(( void )); GLOBAL long Client_MaxUserCount PARAMS(( void ));
GLOBAL long Client_MyMaxUserCount PARAMS(( void )); GLOBAL long Client_MyMaxUserCount PARAMS(( void ));
GLOBAL bool Client_IsValidNick PARAMS(( char *Nick )); GLOBAL bool Client_IsValidNick PARAMS(( const char *Nick ));
GLOBAL WHOWAS *Client_GetWhowas PARAMS(( void )); GLOBAL WHOWAS *Client_GetWhowas PARAMS(( void ));
GLOBAL int Client_GetLastWhowasIndex PARAMS(( void )); GLOBAL int Client_GetLastWhowasIndex PARAMS(( void ));