summaryrefslogtreecommitdiff
path: root/Kernel/Net
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2021-04-20 00:12:56 +0300
committerAndreas Kling <kling@serenityos.org>2021-04-19 23:28:02 +0200
commitdbc13e1ea259eeeebc6b71b9e5ba72e435c9bdff (patch)
treee3d69f9c0b909c0ba7012e5098f9f62e1dcf2ea1 /Kernel/Net
parent152c54a00a573f70d798f0d61f965be789a3e116 (diff)
downloadserenity-dbc13e1ea259eeeebc6b71b9e5ba72e435c9bdff.zip
Kernel: Stop treating port 0 (ephemeral auto bind) as a privileged port
Binding to port 0 is used to signal to listen() to bind to any port that is available. (in serenity's case, to the port range of 32768 to 60999, which are not privileged ports)
Diffstat (limited to 'Kernel/Net')
-rw-r--r--Kernel/Net/IPv4Socket.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp
index 7aa4f7945f..0eb43c9cf5 100644
--- a/Kernel/Net/IPv4Socket.cpp
+++ b/Kernel/Net/IPv4Socket.cpp
@@ -112,7 +112,7 @@ KResult IPv4Socket::bind(Userspace<const sockaddr*> user_address, socklen_t addr
auto requested_local_port = ntohs(address.sin_port);
if (!Process::current()->is_superuser()) {
- if (requested_local_port < 1024) {
+ if (requested_local_port > 0 && requested_local_port < 1024) {
dbgln("UID {} attempted to bind {} to port {}", Process::current()->uid(), class_name(), requested_local_port);
return EACCES;
}