Index | Thread | Search

From:
Jan Klemkow <jan@openbsd.org>
Subject:
newsyslog: fix negative size limit bug
To:
tech@openbsd.org
Date:
Tue, 22 Jul 2025 22:45:56 +0200

Download raw body.

Thread
Hi,

If you use a size limit of 2 GByte or more in newsyslog.conf, it went
negaive and does not work as expected.  This is caused by using atoi(3)
for parsing the size limit from the config file.  Changing this function
to strtoll(3) fix this issue.

ok?

bye,
Jan

Index: newsyslog.c
===================================================================
RCS file: /cvs/src/usr.bin/newsyslog/newsyslog.c,v
diff -u -p -r1.116 newsyslog.c
--- newsyslog.c	8 May 2025 15:30:41 -0000	1.116
+++ newsyslog.c	22 Jul 2025 20:35:04 -0000
@@ -563,7 +563,7 @@ nextline:
 		q = parse = missing_field(sob(++parse), errline, lineno);
 		*(parse = son(parse)) = '\0';
 		if (isdigit((unsigned char)*q))
-			working->size = atoi(q) * 1024;
+			working->size = strtoll(q, NULL, 10) * 1024;
 		else
 			working->size = -1;