summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-09-20 09:46:11 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-09-20 09:46:11 +0000
commit368f2563442aa9458b80b13b738a9d07ca99bd9e (patch)
tree50bd1472198e8b29468d3ba17ca33d71cb5b7d11
parent1ea3e3560db4ba758ffdef9f48f53e6f2632bcfd (diff)
do execle() using alloca() for use inside signal handlers (malloc is bad)
-rw-r--r--lib/libc/gen/exec.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/libc/gen/exec.c b/lib/libc/gen/exec.c
index 10d79ac99a5..3b4bd31a713 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.6 1997/07/25 20:30:01 mickey Exp $";
+static char rcsid[] = "$OpenBSD: exec.c,v 1.7 1997/09/20 09:46:10 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
@@ -125,21 +125,32 @@ execle(name, arg, va_alist)
#endif
{
va_list ap;
- int sverrno;
char **argv, **envp;
+ int i;
#ifdef __STDC__
va_start(ap, arg);
#else
va_start(ap);
#endif
- if ((argv = buildargv(ap, arg, &envp)))
- (void)execve(name, argv, envp);
+ for (i = 1; va_arg(ap, char *) != NULL; i++)
+ ;
va_end(ap);
- sverrno = errno;
- free(argv);
- errno = sverrno;
- return (-1);
+
+ argv = alloca (i * sizeof (char *));
+
+#if __STDC__
+ va_start(ap, arg);
+#else
+ va_start(ap);
+#endif
+ argv[0] = (char *) arg;
+ for (i = 1; (argv[i] = (char *) va_arg(ap, char *)) != NULL; i++)
+ ;
+ envp = (char **) va_arg(ap, char **);
+ va_end(ap);
+
+ return execve(name, argv, envp);
}
int