LibWeb: Account for header size when reading MessagePort message payload

Previously, the fact that this wasn't accounted for could lead to a
crash when large messages were received.

(cherry picked from commit 34e465a67e41b82b276050dde0b4b321c2cf1b18)
This commit is contained in:
Tim Ledbetter 2024-07-30 15:04:32 +01:00 committed by Nico Weber
parent 0283f334af
commit cbf1905621

View file

@ -279,7 +279,7 @@ ErrorOr<MessagePort::ParseDecision> MessagePort::parse_message()
[[fallthrough]];
}
case SocketState::Data: {
if (num_bytes_ready < m_socket_incoming_message_size)
if (num_bytes_ready < HEADER_SIZE + m_socket_incoming_message_size)
return ParseDecision::NotEnoughData;
auto payload = m_buffered_data.span().slice(HEADER_SIZE, m_socket_incoming_message_size);