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().
This commit is contained in:
apio 2023-08-07 22:48:21 +02:00
parent f45734c61d
commit 10c892d606
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -55,7 +55,8 @@ Result<u64> 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<String> 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);