On Sat, 10 Oct 2015, Michael McConville wrote:
> FWIW, this is a perfect use case for Coccinelle. Below is what I dredged
> up in src/usr.sbin (diff not yet carefully audited, but apparently
> sane).
These look good to me. bluhm?
Side note: bluhm, please rename the dprintf() macro to something that
doesn't conflict with the <stdio.h> dprintf() function. I *strongly*
recommend that, as a macro, you use something in all caps so that readers
have fair warning that evaluation may not follow the normal rules.
Philip
> --- syslogd/syslogd.c
> +++ /tmp/cocci-output-17550-6b6404-syslogd.c
> @@ -1126,7 +1126,7 @@ octet_counting(struct evbuffer *evbuf, c
> * It can be assumed that octet-counting framing is used if a syslog
> * frame starts with a digit.
> */
> - if (buf >= end || !isdigit(*buf))
> + if (buf >= end || !isdigit((unsigned char)*buf))
> return (-1);
> /*
> * SYSLOG-FRAME = MSG-LEN SP SYSLOG-MSG
> @@ -1134,7 +1134,7 @@ octet_counting(struct evbuffer *evbuf, c
> * We support up to 5 digits in MSG-LEN, so the maximum is 99999.
> */
> for (p = buf; p < end && p < buf + 5; p++) {
> - if (!isdigit(*p))
> + if (!isdigit((unsigned char)*p))
> break;
> }
> if (buf >= p || p >= end || *p != ' ')