From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Proposed syslog patch [Re: [musl] Further bugs in syslog()]
Date: Sat, 23 Mar 2013 17:27:04 -0400 [thread overview]
Message-ID: <20130323212704.GV20323@brightrain.aerifal.cx> (raw)
In-Reply-To: <20130323161755.GN19010@port70.net>
On Sat, Mar 23, 2013 at 05:17:55PM +0100, Szabolcs Nagy wrote:
> looks ok, one nitpick
>
> * Rich Felker <dalias@aerifal.cx> [2013-03-23 00:05:58 -0400]:
> > void openlog(const char *ident, int opt, int facility)
> > @@ -59,7 +54,14 @@ void openlog(const char *ident, int opt, int facility)
> > int cs;
> > pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
> > LOCK(lock);
> > - __openlog(ident, opt, facility);
> > +
> > + free(log_ident);
> > + log_ident = strdup(ident);
>
> this can fail and then log_ident = 0
Yes, this was the intent; there's no way to report errors, and being
in a status of NULL log_ident is the same as the case where it was
never set at all. However I agree with your reasoning below...
> ....
> > @@ -90,14 +89,14 @@ static void _vsyslog(int priority, const char *message, va_list ap)
> > priority, timebuf,
> > log_ident ? log_ident : "",
> > "["+!pid, pid, "]"+!pid);
> > + if (l >= sizeof buf) return;
>
> if ident is longer than buf, then syslog will silently fail here,
> but if ident is so big that strdup fails above it does not fail here
That it violates the principle of least surprise that moderately long
values of log_ident will prevent any log message from appearing, but
insanely long ones will be silently replaced with a blank string.
> maybe we should limit ident to a sensible value and truncate it
> (i dont know if posix allows that but seems more consistent
> and then no dynamic allocation is needed in openlog)
POSIX provides no way to inspect the output that's produced, so there
are no testable conformance requirements on the output...
I think I like your approach: just using a small fixed-size buffer.
Rich
prev parent reply other threads:[~2013-03-23 21:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-23 3:45 Further bugs in syslog() Rich Felker
2013-03-23 3:53 ` Rich Felker
2013-03-23 4:05 ` Proposed syslog patch [Re: [musl] Further bugs in syslog()] Rich Felker
2013-03-23 16:17 ` Szabolcs Nagy
2013-03-23 21:27 ` Rich Felker [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130323212704.GV20323@brightrain.aerifal.cx \
--to=dalias@aerifal.cx \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).