Reduce memory requirements for execve()

This commit is contained in:
Justine Tunney 2021-01-29 22:00:10 -08:00
parent eaca5b3e81
commit 21e1023d28
7 changed files with 35 additions and 32 deletions

View file

@ -47,11 +47,8 @@ textwindows int execve$nt(const char *program, char *const argv[],
close(i);
}
}
for (i = 0; argv[i];) ++i;
i = (i + 1) * sizeof(char *);
argv = memcpy(alloca(i), argv, i);
memcpy(argv, &program, sizeof(program));
rc = ntspawn(argv, envp, NULL, NULL, true, 0, NULL, &startinfo, &procinfo);
rc = ntspawn(program, argv, envp, NULL, NULL, true, 0, NULL, &startinfo,
&procinfo);
if (rc == -1) return -1;
CloseHandle(procinfo.hThread);
do {