diff options
author | peter <peter@FreeBSD.org> | 1999-03-24 02:43:05 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-03-24 02:43:05 +0000 |
commit | 253f61532f59a6b85dcf8048bdfb2fe251fdb0e6 (patch) | |
tree | f88e2cd0d81e10092c5cc5ffc53aa57c56f6d684 | |
parent | 37a06217a969b66e8fd8d79bf8ca158ed70d2c4d (diff) | |
download | FreeBSD-src-253f61532f59a6b85dcf8048bdfb2fe251fdb0e6.zip FreeBSD-src-253f61532f59a6b85dcf8048bdfb2fe251fdb0e6.tar.gz |
Fix a (relatively harmless) braino. I confused myself over the for() loop
that counted the number of elements in argv. The counter is incremented
in the next-iteration section of the loop, not the body, so at termination
it's already "counted" the element that failed the continuation test - in
this case the NULL argv terminator.
Noted by: bde
-rw-r--r-- | lib/libc/gen/exec.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c index 467be81..b3dd5f3 100644 --- a/lib/libc/gen/exec.c +++ b/lib/libc/gen/exec.c @@ -36,7 +36,7 @@ static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93"; #endif static const char rcsid[] = - "$Id: exec.c,v 1.10 1998/10/15 17:14:15 des Exp $"; + "$Id: exec.c,v 1.11 1999/03/23 16:40:34 peter Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -268,7 +268,7 @@ retry: (void)execve(bp, argv, environ); case ENOEXEC: for (cnt = 0; argv[cnt]; ++cnt) ; - memp = alloca((cnt + 3) * sizeof(char *)); + memp = alloca((cnt + 2) * sizeof(char *)); if (memp == NULL) { /* errno = ENOMEM; XXX override ENOEXEC? */ goto done; @@ -276,7 +276,6 @@ retry: (void)execve(bp, argv, environ); memp[0] = "sh"; memp[1] = bp; bcopy(argv + 1, memp + 2, cnt * sizeof(char *)); - memp[cnt + 2] = NULL; (void)execve(_PATH_BSHELL, memp, environ); goto done; case ENOMEM: |