From 6bc45c2b554f689e2f8dc40dc14d56de6bdc34d1 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Thu, 22 Jun 2023 09:29:44 +0100 Subject: [PATCH] preinit: null-terminate argv array for execve --- pkgs/preinit/preinit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/preinit/preinit.c b/pkgs/preinit/preinit.c index b34c95a..e8f4e76 100644 --- a/pkgs/preinit/preinit.c +++ b/pkgs/preinit/preinit.c @@ -39,7 +39,9 @@ char buf[COMMAND_LINE_SIZE]; int main(int argc, char *argv[], char *envp[]) { +#ifndef PREINIT_USE_LIBC asm("la $gp, _gp\nsw $gp,16($sp)"); +#endif char *rootdevice = 0; char *p = buf; write(1, banner, strlen(banner)); @@ -74,7 +76,7 @@ int main(int argc, char *argv[], char *envp[]) AVER(mount("/target/persist/nix", "/target/nix", "bind", MS_BIND, NULL)); - char *exec_args[] = { "activate", "/target" }; + char *exec_args[] = { "activate", "/target", NULL }; fork_exec("/target/persist/activate", exec_args); AVER(chdir("/target"));