From 6f5632ffc0859abc21b1e7f8f07b45f4f69d0cad Mon Sep 17 00:00:00 2001 From: gad Date: Mon, 24 Feb 2003 02:28:46 +0000 Subject: Check the value given for number-of-logs to keep in config-file entries, and error-out if the value is negative (avoiding an infinite loop). PR: bin/30654 (part of it) MFC after: 3 weeks --- usr.sbin/newsyslog/newsyslog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'usr.sbin/newsyslog') diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index ab52ed8..1dcbedc 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -511,8 +511,8 @@ parse_file(char **files) errx(1, "malformed line (missing fields):\n%s", errline); *parse = '\0'; - if (!sscanf(q, "%d", &working->numlogs)) - errx(1, "error in config file; bad number:\n%s", + if (!sscanf(q, "%d", &working->numlogs) || working->numlogs < 0) + errx(1, "error in config file; bad value for count of logs to save:\n%s", errline); q = parse = missing_field(sob(++parse), errline); -- cgit v1.1