From: deraadt Date: Tue, 17 Dec 1996 02:38:39 +0000 (+0000) Subject: strncpy that strerror, found by oliver@secnet.com X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=0786dfdb01858ecc2632ae547298dbc94e86a2c1;p=openbsd strncpy that strerror, found by oliver@secnet.com --- diff --git a/lib/libc/compat-43/getwd.c b/lib/libc/compat-43/getwd.c index 7557ac43a50..12880a9c49c 100644 --- a/lib/libc/compat-43/getwd.c +++ b/lib/libc/compat-43/getwd.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char *rcsid = "$OpenBSD: getwd.c,v 1.2 1996/08/19 08:19:24 tholo Exp $"; +static char *rcsid = "$OpenBSD: getwd.c,v 1.3 1996/12/17 02:38:39 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -49,6 +49,7 @@ getwd(buf) if (p = getcwd(buf, MAXPATHLEN)) return(p); - (void)strcpy(buf, strerror(errno)); + (void)strncpy(buf, strerror(errno), MAXPATHLEN-1); + buf[MAXPATHLEN-1] = '\0'; return((char *)NULL); }