提交 2b2aff37 编写于 作者: R Rich Felker

fix new environment always being null with execle

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.
上级 23b8e3bc
......@@ -14,9 +14,8 @@ int execle(const char *path, const char *argv0, ...)
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);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册