From 10c892d6065706c44668eca7cc07bceee3057b66 Mon Sep 17 00:00:00 2001 From: apio Date: Mon, 7 Aug 2023 22:48:21 +0200 Subject: [PATCH] kernel: Allow null envp in execve() As far as I know, this is not standard, but I'm doing this as a convenience for programs using exec() right after clearenv(). --- kernel/src/sys/exec.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/src/sys/exec.cpp b/kernel/src/sys/exec.cpp index 280ce407..724ea934 100644 --- a/kernel/src/sys/exec.cpp +++ b/kernel/src/sys/exec.cpp @@ -55,7 +55,8 @@ Result sys_execve(Registers* regs, SyscallArgs args) { auto path = TRY(MemoryManager::strdup_from_user(args[0])); auto argv = TRY(copy_string_vector_from_userspace(args[1])); - auto envp = TRY(copy_string_vector_from_userspace(args[2])); + Vector envp; + if (args[2]) envp = TRY(copy_string_vector_from_userspace(args[2])); if ((calculate_userspace_stack_size(argv) + calculate_userspace_stack_size(envp)) > MAX_ARGV_STACK_SIZE) return err(E2BIG);