From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2957 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Proposed syslog patch [Re: [musl] Further bugs in syslog()] Date: Sat, 23 Mar 2013 17:17:55 +0100 Message-ID: <20130323161755.GN19010@port70.net> References: <20130323034538.GS20323@brightrain.aerifal.cx> <20130323040558.GU20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1364055489 9202 80.91.229.3 (23 Mar 2013 16:18:09 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 23 Mar 2013 16:18:09 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2958-gllmg-musl=m.gmane.org@lists.openwall.com Sat Mar 23 17:18:34 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1UJR9N-0001yW-RT for gllmg-musl@plane.gmane.org; Sat, 23 Mar 2013 17:18:34 +0100 Original-Received: (qmail 9553 invoked by uid 550); 23 Mar 2013 16:18:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 9545 invoked from network); 23 Mar 2013 16:18:08 -0000 Content-Disposition: inline In-Reply-To: <20130323040558.GU20323@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2957 Archived-At: looks ok, one nitpick * Rich Felker [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 ... > @@ -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 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) > l2 = vsnprintf(buf+l, sizeof buf - l, message, ap); > if (l2 >= 0) { > - l += l2; > + if (l2 >= sizeof buf - l) l = sizeof buf - 1; > + else l += l2; > if (buf[l-1] != '\n') buf[l++] = '\n'; > - sendto(log_fd, buf, l, 0, (void *)&log_addr, 11); > + send(log_fd, buf, l, 0); > } > - > - UNLOCK(lock); > }