Skip to content

Commit

Permalink
LibWeb: Account for header size when reading MessagePort message payload
Browse files Browse the repository at this point in the history
Previously, the fact that this wasn't accounted for could lead to a
crash when large messages were received.
  • Loading branch information
tcl3 committed Jul 30, 2024
1 parent c1b0e18 commit 28b66f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/MessagePort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 28b66f4

Please sign in to comment.