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.
This commit is contained in:
parent
22259bf85d
commit
d28fa89346
Notes:
sideshowbarker
2024-07-19 09:02:55 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d28fa89346e
1 changed files with 4 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue