tls: fix out-of-bounds read in ClientHelloParser
ClientHelloParser::ParseHeader(data, avail)
potentially accesses data
beyond avail
bytes because it trusts the client to transmit a valid frame length. Sending an impossibly small frame length causes the TLS server to read beyond the buffer provided by the caller.
Guard against this by calling End()
on the ClientHelloParser
when the client transmits an impossibly small frame length.
The test is designed to reliable cause a segmentation fault on Linux and Windows when the buffer overrun occurs, and to trigger a spatial safety violation when compiled with an address sanitizer enabled or when running under valgrind.