This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __xpg_strerror_r should not clobber strerror buffer


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 '-'.

 2011-05-23  Corinna Vinschen  <corinna@vinschen.de>

diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h
index 4d4306b..f911a6c 100644
--- a/winsup/cygwin/cygtls.h
+++ b/winsup/cygwin/cygtls.h
@@ -109,7 +109,7 @@ struct _local_storage
   } select;

   /* strerror */
-  char strerror_buf[sizeof ("Unknown error 4294967295")];
+  char strerror_buf[sizeof ("Unknown error -2147483648")];

   /* times.cc */
   char timezone_buf[20];


-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]