[uClibc] strerror not thread safe (not re enterant)
Paul Brook
paul at codesourcery.com
Fri Jan 7 02:20:55 UTC 2005
On Friday 07 January 2005 02:05, Philip Rakity wrote:
> strerror is not thread safe since it uses a static
> buffer.
Is it supposed to be? The linux manpage says
"[return value] may be modified by a subsequent call to perror() or
strerror()"
FWIW the glibc implementation doesn't look threadsafe either.
> uClibc/libc/string/wstring.c
>
> Shouldn't the static be removed in the code below ?
No. This would leave the return value pointing to an unallocated stack area.
Paul
> char *strerror(int errnum)
> {
> static char buf[_STRERROR_BUFSIZE];
>
> _susv3_strerror_r(errnum, buf, sizeof(buf));
>
> return buf;
> }
More information about the uClibc
mailing list