Kernel: Binding to port 0 will always find unused port

This commit is contained in:
Bananymous 2024-09-22 17:30:01 +03:00
parent 57aec2a733
commit d395cf38b7
1 changed files with 3 additions and 1 deletions

View File

@ -116,7 +116,9 @@ namespace Kernel
return BAN::Error::from_errno(EAFNOSUPPORT); return BAN::Error::from_errno(EAFNOSUPPORT);
auto& sockaddr_in = *reinterpret_cast<const struct sockaddr_in*>(address); auto& sockaddr_in = *reinterpret_cast<const struct sockaddr_in*>(address);
uint16_t port = BAN::host_to_network_endian(sockaddr_in.sin_port); const uint16_t port = BAN::host_to_network_endian(sockaddr_in.sin_port);
if (port == NetworkSocket::PORT_NONE)
return bind_socket_to_unused(socket, address, address_len);
SpinLockGuard _(m_bound_socket_lock); SpinLockGuard _(m_bound_socket_lock);