summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-04-21 16:24:47 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-21 16:31:53 +0200
commit5e4d5a436edd8aec03f04d641988670cb9d22d65 (patch)
treed7212df6f0500aa37133d5082c07eff34acfc698
parent8e9676c28c3917219cd5c85ff03a7b008f2e308d (diff)
downloadserenity-5e4d5a436edd8aec03f04d641988670cb9d22d65.zip
Kernel: Allow sys$bind() on local sockets with short socket address
Previously, we required local socket addresses to be exactly sizeof(sockaddr_un). There was no real reason for this, so let's not enforce it.
-rw-r--r--Kernel/Net/LocalSocket.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp
index 8de56c6545..1bae224909 100644
--- a/Kernel/Net/LocalSocket.cpp
+++ b/Kernel/Net/LocalSocket.cpp
@@ -124,11 +124,11 @@ void LocalSocket::get_peer_address(sockaddr* address, socklen_t* address_size)
ErrorOr<void> LocalSocket::bind(Userspace<sockaddr const*> user_address, socklen_t address_size)
{
VERIFY(setup_state() == SetupState::Unstarted);
- if (address_size != sizeof(sockaddr_un))
+ if (address_size > sizeof(sockaddr_un))
return set_so_error(EINVAL);
sockaddr_un address = {};
- SOCKET_TRY(copy_from_user(&address, user_address, sizeof(sockaddr_un)));
+ SOCKET_TRY(copy_from_user(&address, user_address, address_size));
if (address.sun_family != AF_LOCAL)
return set_so_error(EINVAL);