preinit: null-terminate argv array for execve

This commit is contained in:
Daniel Barlow 2023-06-22 09:29:44 +01:00
parent b898364719
commit 6bc45c2b55

View file

@ -39,7 +39,9 @@ char buf[COMMAND_LINE_SIZE];
int main(int argc, char *argv[], char *envp[]) int main(int argc, char *argv[], char *envp[])
{ {
#ifndef PREINIT_USE_LIBC
asm("la $gp, _gp\nsw $gp,16($sp)"); asm("la $gp, _gp\nsw $gp,16($sp)");
#endif
char *rootdevice = 0; char *rootdevice = 0;
char *p = buf; char *p = buf;
write(1, banner, strlen(banner)); write(1, banner, strlen(banner));
@ -74,7 +76,7 @@ int main(int argc, char *argv[], char *envp[])
AVER(mount("/target/persist/nix", "/target/nix", AVER(mount("/target/persist/nix", "/target/nix",
"bind", MS_BIND, NULL)); "bind", MS_BIND, NULL));
char *exec_args[] = { "activate", "/target" }; char *exec_args[] = { "activate", "/target", NULL };
fork_exec("/target/persist/activate", exec_args); fork_exec("/target/persist/activate", exec_args);
AVER(chdir("/target")); AVER(chdir("/target"));