diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-13 15:00:28 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-13 15:00:28 +0100 |
commit | a9dc332a1131ea3d8ed7540c770f2d41b9413d07 (patch) | |
tree | d37422c55cab7db5310e41661813e58e1f8c970c /Kernel | |
parent | ea6a537b7076bbd4a50472e971d4a982e25a4c72 (diff) | |
download | serenity-a9dc332a1131ea3d8ed7540c770f2d41b9413d07.zip |
IPv4: recvfrom() shouldn't care about what's in the outparam on entry.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/IPv4Socket.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/Kernel/IPv4Socket.cpp b/Kernel/IPv4Socket.cpp index b4b16979ae..3257719c6b 100644 --- a/Kernel/IPv4Socket.cpp +++ b/Kernel/IPv4Socket.cpp @@ -133,18 +133,12 @@ ssize_t IPv4Socket::sendto(const void* data, size_t data_length, int flags, cons ssize_t IPv4Socket::recvfrom(void* buffer, size_t buffer_length, int flags, sockaddr* addr, socklen_t* addr_length) { (void)flags; - if (addr->sa_family != AF_INET) { - kprintf("recvfrom: Bad address family: %u is not AF_INET!\n", addr->sa_family); - return -EAFNOSUPPORT; - } - if (*addr_length < sizeof(sockaddr_in)) return -EINVAL; - *addr_length = sizeof(sockaddr_in); auto peer_address = IPv4Address((const byte*)&((const sockaddr_in*)addr)->sin_addr.s_addr); #ifdef IPV4_SOCKET_DEBUG - kprintf("recvfrom: peer_address=%s\n", peer_address.to_string().characters()); + kprintf("recvfrom: type=%d, source_port=%u\n", type(), source_port()); #endif ByteBuffer packet_buffer; @@ -176,6 +170,8 @@ ssize_t IPv4Socket::recvfrom(void* buffer, size_t buffer_length, int flags, sock auto& ia = *(sockaddr_in*)addr; memcpy(&ia.sin_addr, &m_destination_address, sizeof(IPv4Address)); + ia.sin_family = AF_INET; + *addr_length = sizeof(sockaddr_in); if (type() == SOCK_RAW) { ASSERT(buffer_length >= ipv4_packet.payload_size()); |