From f5d916a8811b706bf224fadc17f2832f899ab52b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 25 Jan 2021 09:35:25 +0100 Subject: [PATCH] Kernel: Make sys$anon_create() fail if size == 0 An empty anonymous file is useless since it cannot be resized anyway, so let's not support creating it. --- Kernel/Syscalls/anon_create.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/Syscalls/anon_create.cpp b/Kernel/Syscalls/anon_create.cpp index 63192c70a1..6756b9688b 100644 --- a/Kernel/Syscalls/anon_create.cpp +++ b/Kernel/Syscalls/anon_create.cpp @@ -35,6 +35,9 @@ int Process::sys$anon_create(size_t size, int options) { REQUIRE_PROMISE(stdio); + if (!size) + return -EINVAL; + if (size % PAGE_SIZE) return -EINVAL;