浏览代码

Kernel: Don't assert on sys$kill() with pid=INT32_MIN

On 32-bit platforms, INT32_MIN == -INT32_MIN, so we can't expect this
to always work:

    if (pid < 0)
        positive_pid = -pid; // may still be negative!

This happens because the -INT32_MIN expression becomes a long and is
then truncated back to an int.

Fixes #1312.
Andreas Kling 5 年之前
父节点
当前提交
d28fa89346
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      Kernel/Process.cpp

+ 4 - 1
Kernel/Process.cpp

@@ -2213,8 +2213,11 @@ int Process::sys$kill(pid_t pid, int signal)
 
     if (signal < 0 || signal >= 32)
         return -EINVAL;
-    if (pid <= 0)
+    if (pid <= 0) {
+        if (pid == INT32_MIN)
+            return -EINVAL;
         return do_killpg(-pid, signal);
+    }
     if (pid == -1) {
         // FIXME: Send to all processes.
         return -ENOTIMPL;