summaryrefslogtreecommitdiff
path: root/Kernel/Net/UDPSocket.cpp
diff options
context:
space:
mode:
authorBrian Gianforcaro <bgianf@serenityos.org>2021-08-01 05:11:49 -0700
committerAndreas Kling <kling@serenityos.org>2021-08-03 18:54:23 +0200
commit720a686a761b476ff0a793b243f6cc2848fffd04 (patch)
tree9f4bf339947849a64c217e41035e49fe672cc206 /Kernel/Net/UDPSocket.cpp
parent8c4785bd10d16ec33b994de38bf444e927dc782a (diff)
downloadserenity-720a686a761b476ff0a793b243f6cc2848fffd04.zip
Kernel: Handle OOM when allocating Packet KBuffers
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 fa66796af2..263c242897 100644
--- a/Kernel/Net/UDPSocket.cpp
+++ b/Kernel/Net/UDPSocket.cpp
@@ -84,8 +84,8 @@ KResultOr<size_t> UDPSocket::protocol_send(const UserOrKernelBuffer& data, size_
auto packet = routing_decision.adapter->acquire_packet_buffer(ipv4_payload_offset + udp_buffer_size);
if (!packet)
return ENOMEM;
- memset(packet->buffer.data() + ipv4_payload_offset, 0, sizeof(UDPPacket));
- auto& udp_packet = *reinterpret_cast<UDPPacket*>(packet->buffer.data() + ipv4_payload_offset);
+ memset(packet->buffer->data() + ipv4_payload_offset, 0, sizeof(UDPPacket));
+ auto& udp_packet = *reinterpret_cast<UDPPacket*>(packet->buffer->data() + ipv4_payload_offset);
udp_packet.set_source_port(local_port());
udp_packet.set_destination_port(peer_port());
udp_packet.set_length(udp_buffer_size);
@@ -94,7 +94,7 @@ KResultOr<size_t> UDPSocket::protocol_send(const UserOrKernelBuffer& data, size_
routing_decision.adapter->fill_in_ipv4_header(*packet, local_address(), routing_decision.next_hop,
peer_address(), IPv4Protocol::UDP, udp_buffer_size, ttl());
- routing_decision.adapter->send_packet({ packet->buffer.data(), packet->buffer.size() });
+ routing_decision.adapter->send_packet(packet->bytes());
return data_length;
}