Ver código fonte

Kernel: Process::exec(): Check if path is a regular file

https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html

  [EACCES] The new process image file is not a regular file and the
           implementation does not support execution of files of its
           type.

Let's check whether the passed `path` is indeed a regular file.
Jelle Raaijmakers 4 anos atrás
pai
commit
f6d372b2ab
1 arquivos alterados com 3 adições e 0 exclusões
  1. 3 0
      Kernel/Syscalls/execve.cpp

+ 3 - 0
Kernel/Syscalls/execve.cpp

@@ -827,6 +827,9 @@ KResult Process::exec(String path, Vector<String> arguments, Vector<String> envi
     auto description = file_or_error.release_value();
     auto metadata = description->metadata();
 
+    if (!metadata.is_regular_file())
+        return EACCES;
+
     // Always gonna need at least 3 bytes. these are for #!X
     if (metadata.size < 3)
         return ENOEXEC;