Commit ba01e02b authored by Per Cederqvist's avatar Per Cederqvist

(assign_text_no): Don't use isdigit

	unless isascii is true.  Use an int as argument to isalpha and
	isdigit to avoid problems with signed chars.
(assign_conf_no): Likewise.
(assign_int): Likewise.
(rcsid): Added a missing const.
parent e11f9b95
/* /*
* $Id: conf-file.c,v 1.9 1995/11/02 21:48:32 ceder Exp $ * $Id: conf-file.c,v 1.10 1998/07/08 16:13:46 ceder Exp $
* Copyright (C) 1994, 1995 Lysator Academic Computer Association. * Copyright (C) 1994, 1995 Lysator Academic Computer Association.
* *
* This file is part of the LysKOM server. * This file is part of the LysKOM server.
...@@ -26,7 +26,8 @@ ...@@ -26,7 +26,8 @@
* Read configuration files. * Read configuration files.
*/ */
static char *rcsid = "$Id: conf-file.c,v 1.9 1995/11/02 21:48:32 ceder Exp $"; static const char *
rcsid = "$Id: conf-file.c,v 1.10 1998/07/08 16:13:46 ceder Exp $";
#include "rcs.h" #include "rcs.h"
USE(rcsid); USE(rcsid);
...@@ -234,9 +235,13 @@ Success ...@@ -234,9 +235,13 @@ Success
assign_text_no(const char *val, assign_text_no(const char *val,
const struct parameter *par) const struct parameter *par)
{ {
int c;
/* FIXME: use strtol */
if (val != NULL) if (val != NULL)
{ {
if (!isdigit(*val)) c = (unsigned char)*val;
if (!isascii(c) || !isdigit(c))
return FAILURE; return FAILURE;
*(Text_no*)par->value = atol(val); *(Text_no*)par->value = atol(val);
} }
...@@ -247,9 +252,13 @@ Success ...@@ -247,9 +252,13 @@ Success
assign_conf_no(const char *val, assign_conf_no(const char *val,
const struct parameter *par) const struct parameter *par)
{ {
int c;
/* FIXME: use strtol */
if (val != NULL) if (val != NULL)
{ {
if (!isdigit(*val)) c = (unsigned char)*val;
if (!isascii(c) || !isdigit(c))
return FAILURE; return FAILURE;
*(Conf_no*)par->value = atol(val); *(Conf_no*)par->value = atol(val);
} }
...@@ -260,9 +269,13 @@ Success ...@@ -260,9 +269,13 @@ Success
assign_int(const char *val, assign_int(const char *val,
const struct parameter *par) const struct parameter *par)
{ {
int c;
/* FIXME: use strtol */
if (val != NULL) if (val != NULL)
{ {
if (!isdigit(*val) && *val != '-') c = (unsigned char)*val;
if ((!isascii(c) || !isdigit(c)) && c != '-')
return FAILURE; return FAILURE;
*(int*)par->value = atol(val); *(int*)par->value = atol(val);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment