From owner-freebsd-standards@FreeBSD.ORG Thu Oct 7 06:01:01 2004 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9A72716A56F for ; Thu, 7 Oct 2004 06:01:01 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E1A843D2D for ; Thu, 7 Oct 2004 06:01:01 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i97611iq098348 for ; Thu, 7 Oct 2004 06:01:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i97610GA098343; Thu, 7 Oct 2004 06:01:01 GMT (envelope-from gnats) Date: Thu, 7 Oct 2004 06:01:01 GMT Message-Id: <200410070601.i97610GA098343@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Dan Nelson Subject: Re: standards/72394: [PATCH] syslog is not thread-safe X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dan Nelson List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 Oct 2004 06:01:01 -0000 The following reply was made to PR standards/72394; it has been noted by GNATS. From: Dan Nelson To: FreeBSD-gnats-submit@FreeBSD.org Cc: Subject: Re: standards/72394: [PATCH] syslog is not thread-safe Date: Thu, 7 Oct 2004 00:58:43 -0500 Update: if errno isn't valid, strerror() isn't thread-safe, so here's an addon patch that uses strerror_r instead: --- syslog.c~ Thu Oct 7 00:39:44 2004 +++ syslog.c Thu Oct 7 00:49:06 2004 @@ -139,7 +139,7 @@ vsyslog(pri, fmt, ap) char ch, *p; time_t now; int fd, saved_errno; - char *stdp, tbuf[2048], fmt_cpy[1024], timbuf[26]; + char *stdp, tbuf[2048], fmt_cpy[1024], timbuf[26], errstr[64]; FILE *fp, *fmt_fp; struct bufcookie tbuf_cookie; struct bufcookie fmt_cookie; @@ -215,7 +215,8 @@ vsyslog(pri, fmt, ap) for ( ; (ch = *fmt); ++fmt) { if (ch == '%' && fmt[1] == 'm') { ++fmt; - fputs(strerror(saved_errno), fmt_fp); + strerror_r(saved_errno, errstr, sizeof(errstr)); + fputs(errstr, fmt_fp); } else if (ch == '%' && fmt[1] == '%') { ++fmt; fputc(ch, fmt_fp);