about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2011-01-18 22:41:27 +0100
committerAlexander Barton <alex@barton.de>2011-01-18 22:41:27 +0100
commit58a4dae56dd34e41b32dd3e5cede03a7ea5c7bb5 (patch)
tree12d59a516b1674c23c784d3327b51b9fdea001e6
parent914d6a26d85ecaf7e0962c40392769cf4764e987 (diff)
downloadngircd-58a4dae56dd34e41b32dd3e5cede03a7ea5c7bb5.tar.gz
ngircd-58a4dae56dd34e41b32dd3e5cede03a7ea5c7bb5.zip
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".
-rw-r--r--configure.in2
-rw-r--r--src/ngircd/conf.c41
2 files changed, 15 insertions, 28 deletions
diff --git a/configure.in b/configure.in
index 9a368432..5e334963 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 fa22df05..e1fb73be 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;
 	}