Download raw body.
newsyslog: fix negative size limit bug
Jan Klemkow <jan@openbsd.org> wrote:
> - if (isdigit((unsigned char)*q))
> - working->size = atoi(q) * 1024;
> - else
> + if (isdigit((unsigned char)*q)) {
> + working->size = strtonum(q, 0, INT64_MAX/1024, &errstr);
> + if (errstr) {
> + warnx("%s:%d: invalid size %s (%s)"
> + " --> skipping", conf, lineno, q, errstr);
> + ret = 1;
> + goto nextline;
> + }
> + working->size *= 1024;
> + } else
The (pre-existing) use of isdigit() is pretty strange.
This is probably handling this:
If this field is replaced by an `*', or set to `0',
then the size of the log file is not taken into account
when determining when to trim the log file. By
But basically you could put any garbage in the field, and it will behave
like '*' or '0'? That seems a bit imprecise. It should probably parse for
'*' specifically, then call strtonum() which would include the 0 case, and
then anything else is an error.
newsyslog: fix negative size limit bug