mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 06:48:12 +00:00
Kernel: Check against TCP packet size overflows in checksum calculation
This commit is contained in:
parent
24f956c739
commit
30a553ef80
1 changed files with 5 additions and 1 deletions
|
@ -372,7 +372,11 @@ NetworkOrdered<u16> TCPSocket::compute_tcp_checksum(IPv4Address const& source, I
|
||||||
};
|
};
|
||||||
static_assert(sizeof(PseudoHeader) == 12);
|
static_assert(sizeof(PseudoHeader) == 12);
|
||||||
|
|
||||||
PseudoHeader pseudo_header { .header = { source, destination, 0, (u8)IPv4Protocol::TCP, packet.header_size() + payload_size } };
|
Checked<u16> packet_size = packet.header_size();
|
||||||
|
packet_size += payload_size;
|
||||||
|
VERIFY(!packet_size.has_overflow());
|
||||||
|
|
||||||
|
PseudoHeader pseudo_header { .header = { source, destination, 0, (u8)IPv4Protocol::TCP, packet_size.value() } };
|
||||||
|
|
||||||
u32 checksum = 0;
|
u32 checksum = 0;
|
||||||
auto* raw_pseudo_header = pseudo_header.raw;
|
auto* raw_pseudo_header = pseudo_header.raw;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue