summaryrefslogtreecommitdiff
path: root/Kernel/Net/UDPSocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/Net/UDPSocket.cpp')
-rw-r--r--Kernel/Net/UDPSocket.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Net/UDPSocket.cpp b/Kernel/Net/UDPSocket.cpp
index 70a96e5066..fb08f20180 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -64,10 +64,10 @@ KResultOr<size_t> UDPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, Use
auto& ipv4_packet = *(const IPv4Packet*)(raw_ipv4_packet.data());
auto& udp_packet = *static_cast<const UDPPacket*>(ipv4_packet.payload());
VERIFY(udp_packet.length() >= sizeof(UDPPacket)); // FIXME: This should be rejected earlier.
- VERIFY(buffer_size >= (udp_packet.length() - sizeof(UDPPacket)));
- if (!buffer.write(udp_packet.payload(), udp_packet.length() - sizeof(UDPPacket)))
+ size_t read_size = min(buffer_size, udp_packet.length() - sizeof(UDPPacket));
+ if (!buffer.write(udp_packet.payload(), read_size))
return EFAULT;
- return udp_packet.length() - sizeof(UDPPacket);
+ return read_size;
}
KResultOr<size_t> UDPSocket::protocol_send(const UserOrKernelBuffer& data, size_t data_length)