From 76aa3dd62e5e4b02cca65819f1c8d9938aec06fd Mon Sep 17 00:00:00 2001 From: espie <> Date: Mon, 3 May 2004 05:07:34 +0000 Subject: build the error message in strerror_r.c directly, avoiding one copy there. handle a few subtle details caught by the regression tests: correct termination, non copying if buffer length == 0, errno setting. let all former users of __strerror go through strerror_r. Work by Todd Miller and I. Okay millert@. --- src/lib/libc/string/strerror.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/lib/libc/string/strerror.c') diff --git a/src/lib/libc/string/strerror.c b/src/lib/libc/string/strerror.c index 6496f50afd..edb6af7386 100644 --- a/src/lib/libc/string/strerror.c +++ b/src/lib/libc/string/strerror.c @@ -28,23 +28,17 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: strerror.c,v 1.5 2003/06/11 21:08:16 deraadt Exp $"; +static char *rcsid = "$OpenBSD: strerror.c,v 1.6 2004/05/03 05:07:34 espie Exp $"; #endif /* LIBC_SCCS and not lint */ #include #include -/* - * Since perror() is not allowed to change the contents of strerror()'s - * static buffer, both functions supply their own buffers to the - * internal function __strerror(). - */ - -extern char *__strerror(int, char *); - char * strerror(int num) { static char buf[NL_TEXTMAX]; - return __strerror(num, buf); + + (void)strerror_r(num, buf, sizeof(buf)); + return (buf); } -- cgit v1.2.3-55-g6feb