From bedb455962e86ad0b0160b1bc6d7ceb499e07e27 Mon Sep 17 00:00:00 2001 From: Garance A Drosehn Date: Mon, 5 May 2003 22:27:37 +0000 Subject: [PATCH] Slightly improve the checking of the 'size' field, so people will get a warning message if they switch the values for 'size' and 'when'. MFC after: 1 week --- usr.sbin/newsyslog/newsyslog.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index ae5a224eb1ce..d70d744c9814 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -155,6 +155,7 @@ static time_t parseDWM(char *s, char *errline); * range 0 to 255, plus EOF. Define wrappers which can take * values of type 'char', either signed or unsigned. */ +#define isdigitch(Anychar) isdigit(((int) Anychar) & 255) #define isprintch(Anychar) isprint(((int) Anychar) & 255) #define isspacech(Anychar) isspace(((int) Anychar) & 255) #define tolowerch(Anychar) tolower(((int) Anychar) & 255) @@ -949,10 +950,15 @@ parse_file(FILE *cf, const char *cfname, struct conf_entry **work_p, errx(1, "malformed line (missing fields):\n%s", errline); *parse = '\0'; - if (isdigit(*q)) + if (isdigitch(*q)) working->size = atoi(q); - else + else if (strcmp(q,"*") == 0) working->size = -1; + else { + warnx("Invalid value of '%s' for 'size' in line:\n%s", + q, errline); + working->size = -1; + } working->flags = 0; q = parse = missing_field(sob(++parse), errline);