This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
Re: __xpg_strerror_r should not clobber strerror buffer
On Mon, May 23, 2011 at 02:52:12PM -0600, Eric Blake wrote:
>On 05/23/2011 02:45 PM, Eric Blake wrote:
>> On 05/21/2011 07:35 PM, Christopher Faylor wrote:
>>> On Sat, May 21, 2011 at 07:26:37PM -0600, Eric Blake wrote:
>>>> POSIX says that no other function in the standard should clobber the
>>>> strerror buffer. Our strerror_r is a GNU extension, so it can get away
>>>> with clobbering the buffer (but if we wanted to fix it, we would have to
>>>> separate _my_tls.locals.strerror_buf into two different buffers).
>
>Shoot. This introduced an off-by-one buffer overrun. I'm pushing this
>followup. Meanwhile, do we want a second buffer, so that the GNU
>strerror_r won't clobber the strerror buffer?
>
>+++ b/winsup/cygwin/ChangeLog
>@@ -2,6 +2,7 @@
>
> * errno.cc (strerror): Print unknown errno as int.
> (__xpg_strerror_r): Likewise, and don't clobber strerror buffer.
>+ * cygtls.h (strerror_buf): Resize to allow '-'.
Please don't send ChangeLog diffs.
The patch is approved. I don't know if I care whether strerror_r
clobbers strerror.
Thanks.
cgf