瀏覽代碼

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.
Andreas Kling 4 年之前
父節點
當前提交
f5d916a881
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      Kernel/Syscalls/anon_create.cpp

+ 3 - 0
Kernel/Syscalls/anon_create.cpp

@@ -35,6 +35,9 @@ int Process::sys$anon_create(size_t size, int options)
 {
 {
     REQUIRE_PROMISE(stdio);
     REQUIRE_PROMISE(stdio);
 
 
+    if (!size)
+        return -EINVAL;
+
     if (size % PAGE_SIZE)
     if (size % PAGE_SIZE)
         return -EINVAL;
         return -EINVAL;