[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: perror bug
From: |
Bruno Haible |
Subject: |
Re: perror bug |
Date: |
Thu, 19 May 2011 21:07:32 +0200 |
User-agent: |
KMail/1.9.9 |
> +# elif defined __sgi || (defined __sun && !defined _LP64) /* IRIX, Solaris
> <= 9 32-bit */
> +
> + /* For a valid error number, the system's strerror() function returns
> + a pointer to a not copied string, not to a buffer. */
Just for reference: How to find out whether a closed-source strerror()
function uses a buffer or not. Run this program and observe whether
all three addresses are the same or not.
===============================================================================
#include <errno.h>
#include <stdio.h>
#include <string.h>
int main ()
{
const char *msg1;
const char *msg2;
const char *msg3;
msg1 = strerror (ENOENT);
printf ("msg1 before: %p %s\n", msg1, msg1);
msg2 = strerror (ENOTDIR);
printf ("msg2 before: %p %s\n", msg2, msg2);
msg3 = strerror (0);
printf ("msg3 before: %p %s\n", msg3, msg3);
strerror (ENOENT);
strerror (ENOTDIR);
strerror (0);
printf ("msg1 after: %s\n", msg1);
printf ("msg2 after: %s\n", msg2);
printf ("msg3 after: %s\n", msg3);
return 0;
}
===============================================================================
--
In memoriam Anne Boleyn <http://en.wikipedia.org/wiki/Anne_Boleyn>