Replace usage of strerror()/strcpy() with strerror_r() here, reducing

number of required operations to get error message and avoiding of strerror's
buffer clobbering.

Also ANSI'fy prototypes while I'm here
This commit is contained in:
Alexey Zelkin 2005-02-27 14:51:27 +00:00
parent 923d9b0109
commit 75667314a9

View file

@ -41,16 +41,14 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
char *
getwd(buf)
char *buf;
getwd(char *buf)
{
char *p;
if ( (p = getcwd(buf, MAXPATHLEN)) )
return(p);
(void)strcpy(buf, strerror(errno));
(void)strerror_r(errno, buf, MAXPATHLEN);
return((char *)NULL);
}