> From: "Todd C. Miller" <todd.mil...@courtesan.com> > Date: Wed, 19 Oct 2016 09:11:36 -0600 > > Currently, syslog_r() avoids using strerror() since it is not > reentrant. We have a reentrant strerror_r() so let's use it. > > OK?
Perhaps add a comment explicitly stating that OpenBSD's strerror_r() *is* reentrant? > Index: lib/libc/gen/syslog_r.c > =================================================================== > RCS file: /cvs/src/lib/libc/gen/syslog_r.c,v > retrieving revision 1.15 > diff -u -p -u -r1.15 syslog_r.c > --- lib/libc/gen/syslog_r.c 27 Mar 2016 16:28:56 -0000 1.15 > +++ lib/libc/gen/syslog_r.c 19 Oct 2016 15:06:48 -0000 > @@ -138,17 +138,16 @@ __vsyslog_r(int pri, struct syslog_data > } > } > > - /* strerror() is not reentrant */ > - > for (t = fmt_cpy, fmt_left = FMT_LEN; (ch = *fmt); ++fmt) { > if (ch == '%' && fmt[1] == 'm') { > + char ebuf[NL_TEXTMAX]; > + > ++fmt; > - if (reentrant) { > + if (strerror_r(saved_errno, ebuf, sizeof(ebuf)) != 0) { > prlen = snprintf(t, fmt_left, "Error %d", > saved_errno); > } else { > - prlen = snprintf(t, fmt_left, "%s", > - strerror(saved_errno)); > + prlen = snprintf(t, fmt_left, "%s", ebuf); > } > if (prlen < 0) > prlen = 0; > >