Module: ngircd.git Branch: master Commit: 58a4dae56dd34e41b32dd3e5cede03a7ea5c7bb5 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=58a4d...
Author: Alexander Barton alex@barton.de Date: Tue Jan 18 22:41:27 2011 +0100
conf: fix 'Value of "..." is not a number!' for negative values
Don't use isdigit() function any more, because it only checks the first character of the variable value and because it doesn't know about the minus sign which is required e.g. for "Group = -1".
---
configure.in | 2 +- src/ngircd/conf.c | 41 ++++++++++++++--------------------------- 2 files changed, 15 insertions(+), 28 deletions(-)
diff --git a/configure.in b/configure.in index 9a36843..5e33496 100644 --- a/configure.in +++ b/configure.in @@ -162,7 +162,7 @@ AC_CHECK_FUNCS([ \ bind gethostbyaddr gethostbyname gethostname inet_ntoa \ setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
-AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction sigprocmask snprintf \ +AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton sigaction sigprocmask snprintf \ vsnprintf strdup strlcpy strlcat strtok_r)
# -- Configuration options -- diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index fa22df0..e1fb73b 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -1055,11 +1055,9 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) pwd = getpwnam( Arg ); if( pwd ) Conf_UID = pwd->pw_uid; else { -#ifdef HAVE_ISDIGIT - if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var ); - else -#endif Conf_UID = (unsigned int)atoi( Arg ); + if (!Conf_UID && strcmp(Arg, "0")) + Config_Error_NaN(Line, Var); } return; } @@ -1068,11 +1066,9 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) grp = getgrnam( Arg ); if( grp ) Conf_GID = grp->gr_gid; else { -#ifdef HAVE_ISDIGIT - if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var ); - else -#endif - Conf_GID = (unsigned int)atoi( Arg ); + Conf_GID = (unsigned int)atoi(Arg); + if (!Conf_GID && strcmp(Arg, "0")) + Config_Error_NaN( Line, Var ); } return; } @@ -1153,29 +1149,23 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) } if( strcasecmp( Var, "MaxConnections" ) == 0 ) { /* Maximum number of connections. 0 -> "no limit". */ -#ifdef HAVE_ISDIGIT - if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var); - else -#endif Conf_MaxConnections = atol( Arg ); + if (!Conf_MaxConnections && strcmp(Arg, "0")) + Config_Error_NaN(Line, Var); return; } if( strcasecmp( Var, "MaxConnectionsIP" ) == 0 ) { /* Maximum number of simultaneous connections from one IP. 0 -> "no limit" */ -#ifdef HAVE_ISDIGIT - if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var ); - else -#endif Conf_MaxConnectionsIP = atoi( Arg ); + if (!Conf_MaxConnectionsIP && strcmp(Arg, "0")) + Config_Error_NaN(Line, Var); return; } if( strcasecmp( Var, "MaxJoins" ) == 0 ) { /* Maximum number of channels a user can join. 0 -> "no limit". */ -#ifdef HAVE_ISDIGIT - if( ! isdigit( (int)*Arg )) Config_Error_NaN( Line, Var ); - else -#endif Conf_MaxJoins = atoi( Arg ); + if (!Conf_MaxJoins && strcmp(Arg, "0")) + Config_Error_NaN(Line, Var); return; } if( strcasecmp( Var, "MaxNickLength" ) == 0 ) { @@ -1386,12 +1376,9 @@ Handle_SERVER( int Line, char *Var, char *Arg ) #endif if( strcasecmp( Var, "Group" ) == 0 ) { /* Server group */ -#ifdef HAVE_ISDIGIT - if( ! isdigit( (int)*Arg )) - Config_Error_NaN( Line, Var ); - else -#endif New_Server.group = atoi( Arg ); + if (!New_Server.group && strcmp(Arg, "0")) + Config_Error_NaN(Line, Var); return; } if( strcasecmp( Var, "Passive" ) == 0 ) { @@ -1479,7 +1466,7 @@ Handle_CHANNEL(int Line, char *Var, char *Arg) if( strcasecmp( Var, "MaxUsers" ) == 0 ) { /* maximum user limit, mode l */ chan->maxusers = (unsigned long) atol(Arg); - if (chan->maxusers == 0) + if (!chan->maxusers && strcmp(Arg, "0")) Config_Error_NaN(Line, Var); return; }