Date: Sat, 1 Jun 2002 23:58:00 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Dag-Erling Smorgrav <des@ofug.org> Cc: Dima Dorfman <dima@trit.org>, <audit@FreeBSD.ORG> Subject: Re: %j for printf(9) Message-ID: <20020601233017.Q2458-100000@gamplex.bde.org> In-Reply-To: <xzpg0088ag5.fsf@flood.ping.uio.no>
next in thread | previous in thread | raw e-mail | index | archive | help
On 31 May 2002, Dag-Erling Smorgrav wrote:
> Complete updated patch attached.
> Index: sys/kern/subr_prf.c
> ===================================================================
> RCS file: /home/ncvs/src/sys/kern/subr_prf.c,v
> retrieving revision 1.81
> diff -u -r1.81 subr_prf.c
> --- sys/kern/subr_prf.c 29 Apr 2002 09:15:38 -0000 1.81
> +++ sys/kern/subr_prf.c 31 May 2002 16:58:16 -0000
> ...
> @@ -491,19 +473,19 @@
> kvprintf(char const *fmt, void (*func)(int, void*), void *arg, int radix, va_list ap)
> {
> #define PCHAR(c) {int cc=(c); if (func) (*func)(cc,arg); else *d++ = cc; retval++; }
> + const char *percent;
Should be with the other char *'s.
> char nbuf[MAXNBUF];
> char *p, *q, *d;
> u_char *up;
> int ch, n;
> - u_long ul;
> - u_quad_t uq;
> - int base, lflag, qflag, tmp, width, ladjust, sharpflag, neg, sign, dot;
> + uintmax_t num;
> + int base, lflag, jflag, qflag, tmp, width;
> + int ladjust, sharpflag, neg, sign, dot;
When splitting this, you might consider fixing he disorder in it (but fixing
the external disorder and misarrangement of the other declarations of ints
should be in a separate patch).
> @@ -519,13 +501,15 @@
> padc = ' ';
> width = 0;
> while ((ch = (u_char)*fmt++) != '%') {
> - if (ch == '\0')
> + if (ch == '\0')
Unrelated style fix :-).
> PCHAR(ch);
> }
> - qflag = 0; lflag = 0; ladjust = 0; sharpflag = 0; neg = 0;
> - sign = 0; dot = 0; dwidth = 0;
> -reswitch: switch (ch = (u_char)*fmt++) {
> + percent = fmt - 1;
> + qflag = jflag = lflag = ladjust = sharpflag =
> + neg = sign = dot = dwidth = 0;
> +reswitch:
> + switch (ch = (u_char)*fmt++) {
Another unrelated style fix. This one makes the patch harder to read.
> @@ -646,15 +621,8 @@
> goto reswitch;
> case 'n':
> case 'r':
> - if (qflag)
> - uq = va_arg(ap, u_quad_t);
Please remove the 'n' case, and check this a bit. I forgot to remove it
soon after rev.1.48.
> @@ -752,10 +717,8 @@
>
> break;
> default:
> - PCHAR('%');
> - if (lflag)
> - PCHAR('l');
> - PCHAR(ch);
> + while (percent < fmt)
> + PCHAR(*percent++);
> break;
> }
> }
This seems to print all the garbage for %<garbage>. It might be useful
to mark up the garbage. But gcc will detect the garbage at compile time
for literal strings.
> @@ -908,7 +871,7 @@
> }
>
> SYSCTL_PROC(_kern, OID_AUTO, msgbuf_clear,
> - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0,
> + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE, &msgbuf_clear, 0,
Unrelated style fix :-).
I like the bulk of the patch.
Bruce
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020601233017.Q2458-100000>
