In message: <[EMAIL PROTECTED]>
            Alfred Perlstein <[EMAIL PROTECTED]> writes:
: syslog(3) botches things if you pass it a string that has "%%m" in it.
: this should fix it, any comments?
: 
: Index: syslog.c
: ===================================================================
: RCS file: /home/ncvs/src/lib/libc/gen/syslog.c,v
: retrieving revision 1.28
: diff -u -r1.28 syslog.c
: --- syslog.c  14 Nov 2002 12:40:14 -0000      1.28
: +++ syslog.c  8 Feb 2003 21:08:09 -0000
: @@ -190,12 +190,18 @@
:               }
:  
:               /* Substitute error message for %m. */
: -             for ( ; (ch = *fmt); ++fmt)
: +             for ( ; (ch = *fmt); ++fmt) {
:                       if (ch == '%' && fmt[1] == 'm') {
:                               ++fmt;
:                               fputs(strerror(saved_errno), fmt_fp);
: -                     } else
: +                     } else if (ch == '%' && fmt[1] == '%') {
: +                             ++fmt;
: +                             fputc(ch, fmt_fp);
: +                             fputc(ch, fmt_fp);
: +                     } else {
:                               fputc(ch, fmt_fp);
: +                     }
: +             }
:  
:               /* Null terminate if room */
:               fputc(0, fmt_fp);
: 

With the above fix, "fred %%m" will produce
'fred %%ERRNO-ERROR-MESSAGE' would it not?  Isn't there one too many
fputc(ch, fmt_fp) in the case where you detect %%? 

+                               ++fmt;
+                               fputc(ch, fmt_fp);

instead in the '%%' if statement.  This would print only one '%' ala
printf.

Warner


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to