bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: perror bug


From: Eric Blake
Subject: Re: perror bug
Date: Wed, 09 Feb 2011 19:28:25 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.7

On 02/09/2011 05:48 PM, Eric Blake wrote:
> POSIX requires that this program have an identical first and last line:
> 
> #include <stdio.h>
> #include <string.h>
> #include <errno.h>
> int main (void) {
>   char *err = strerror(1000);
>   printf ("%s\n", err);
>   errno = 2000;
>   perror ("hi");
>   printf ("%s\n", err);
>   return 0;
> }
> 
> but on cygwin 1.7.7, the perror() corrupts the buffer returned by
> strerror().  We should probably fix that in gnulib as part of our perror
> module.

Actually, maybe the fix to this is to make sure that we always replace
strerror(), and strcpy() the output into a secondary buffer (other libc
functions that incorrectly call strerror() will not overwrite our
secondary buffer), and make sure that the rest of gnulib uses only
strerror_r() rather than strerror() (although that means making more
modules dependent on strerror_r-posix, such as perror).

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]