From 0e3b7dd62f00bc51db18ed8d9b2eba4fa208b948 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 30 Jul 2002 00:15:14 +0000 Subject: be even more careful with strlcpy() --- lib/libc/gen/exec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index 9341d4f4c4d..b47f3b15b04 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: exec.c,v 1.12 2002/02/19 19:39:36 millert Exp $"; +static char rcsid[] = "$OpenBSD: exec.c,v 1.13 2002/07/30 00:15:13 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include @@ -142,7 +142,7 @@ execvp(name, argv) char * const *argv; { char **memp; - register int cnt, lp, ln; + register int cnt, lp, ln, len; register char *p; int eacces = 0; char *bp, *cur, *path, buf[MAXPATHLEN]; @@ -166,12 +166,13 @@ execvp(name, argv) /* Get the path we're searching. */ if (!(path = getenv("PATH"))) path = _PATH_DEFPATH; - cur = alloca(strlen(path) + 1); + len = strlen(path) + 1; + cur = alloca(len); if (cur == NULL) { errno = ENOMEM; return (-1); } - strcpy(cur, path); + strlcpy(cur, path, len); path = cur; while ((p = strsep(&cur, ":"))) { /* -- cgit v1.2.3