Browse Source

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.
Rich Felker 11 năm trước cách đây
mục cha
commit
2b2aff37ac
1 tập tin đã thay đổi với 1 bổ sung2 xóa
  1. 1 2
      src/process/execle.c

+ 1 - 2
src/process/execle.c

@@ -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);
 	}