Kernel: Accept SHUT_RD and SHUT_WR as shutdown() how values

The previous check for valid how values assumed this field was a bitmap
and that SHUT_RDWR was simply a bitwise or of SHUT_RD and SHUT_WR,
which is not the case.
This commit is contained in:
Idan Horowitz 2022-07-09 22:26:58 +03:00 committed by Andreas Kling
parent 693d34fe3d
commit a6f237a247
Notes: sideshowbarker 2024-07-17 18:49:10 +09:00

View file

@ -160,7 +160,7 @@ ErrorOr<FlatPtr> Process::sys$shutdown(int sockfd, int how)
{
VERIFY_NO_PROCESS_BIG_LOCK(this)
TRY(require_promise(Pledge::stdio));
if (how & ~SHUT_RDWR)
if (how != SHUT_RD && how != SHUT_WR && how != SHUT_RDWR)
return EINVAL;
auto description = TRY(open_file_description(sockfd));
if (!description->is_socket())