the va_arg call for the argv[]-terminating null pointer was missing,
so this pointer was being wrongly used as the environment pointer.
issue reported by Timo Teräs. proposed patch slightly modified to
simplify the resulting code.
char **envp;
va_start(ap, argv0);
argv[0] = (char *)argv0;
- for (i=1; i<argc; i++)
+ for (i=1; i<=argc; i++)
argv[i] = va_arg(ap, char *);
- argv[i] = NULL;
envp = va_arg(ap, char **);
return execve(path, argv, envp);
}