Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 07 Feb 2001 16:18:45 -0700
From:      Warner Losh <imp@harmony.village.org>
To:        Mike Heffner <mheffner@vt.edu>
Cc:        FreeBSD-audit <FreeBSD-audit@FreeBSD.ORG>
Subject:   Re: lam(1) patch 
Message-ID:  <200102072318.f17NIj996425@harmony.village.org>
In-Reply-To: Your message of "Wed, 07 Feb 2001 18:00:49 EST." <XFMail.20010207180049.mheffner@vt.edu> 
References:  <XFMail.20010207180049.mheffner@vt.edu>  

next in thread | previous in thread | raw e-mail | index | archive | help
In message <XFMail.20010207180049.mheffner@vt.edu> Mike Heffner writes:
: | Also available from:
: | http://filebox.vt.edu/users/mheffner/patches/lam.patch
: Any objections to me committing this? 


@@ -130,7 +131,7 @@
                        ip++;
                        continue;
                }
-               switch (*(c = ++p) | 040) {
+               switch (tolower(*(c = ++p))) {
                case 's':
                        if (*++p || (p = *++av))
                                ip->sepstring = p;

The tolower function will only evaluate the arguments once, but the
tolower macro might evaluate them multiple times.  Maybe I'm recalling
things too far back.  In any event, I'd be tempted to write it like:

+               c = ++p;
+               switch (tolower(*c)) {


@@ -175,13 +182,12 @@
 pad(ip)
        struct openfile *ip;
 {
-       register char *p = ip->sepstring;
-       register char *lp = linep;
+       char *lp = linep;
 
-       while (*p)
-               *lp++ = *p++;
+       strlcpy(lp, ip->sepstring, line + sizeof(line) - lp);
+       lp += strlen(lp);
        if (ip->pad) {
-               sprintf(lp, ip->format, "");
+               snprintf(lp, line + sizeof(line) - lp, ip->format, "");
                lp += strlen(lp);
        }
        return (lp);

This appaers to introduce an extra dependencies on line.  However,
pad() and gatherline() already depend on this to an unhealthy degree,
so you aren't introducing any really gross.  The code is already
somewhat gross :-(.

: Also, should I follow it up with a de-__P() patch?

Yes.  So long as you make all the old K&R style decls into ANSI ones
at the same time.

Warner


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?200102072318.f17NIj996425>