Skip to content

Commit

Permalink
Kernel: Make sure outgoing ICMP packets have the correct checksum
Browse files Browse the repository at this point in the history
The internet_checksum() function relies on the buffer - or at least the
checksum field - to be all zeroes.
  • Loading branch information
gunnarbeutner authored and awesomekling committed Jun 3, 2021
1 parent c4c577b commit 7f7897c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Kernel/Net/NetworkTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ void handle_icmp(const EthernetFrameHeader& eth, const IPv4Packet& ipv4_packet,
return;
}
adapter->fill_in_ipv4_header(*packet, adapter->ipv4_address(), eth.source(), ipv4_packet.source(), IPv4Protocol::ICMP, icmp_packet_size, 64);
memset(packet->buffer.data() + ipv4_payload_offset, 0, sizeof(ICMPEchoPacket));
auto& response = *(ICMPEchoPacket*)(packet->buffer.data() + ipv4_payload_offset);
response.header.set_type(ICMPType::EchoReply);
response.header.set_code(0);
Expand Down

0 comments on commit 7f7897c

Please sign in to comment.