Skip to content

Commit 7a14903

Browse files
Sam Lanciadaenney
authored andcommitted
Fix OOB read in server hello
This fixes an out of bounds read when we're unmarshalling the Server Hello. This could cause us to panic.
1 parent 8b8bc87 commit 7a14903

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

pkg/protocol/handshake/message_server_hello.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,14 @@ func (m *MessageServerHello) Unmarshal(data []byte) error {
8888
m.SessionID = append([]byte{}, data[currOffset:currOffset+n]...)
8989
currOffset += len(m.SessionID)
9090

91+
if len(data) < currOffset+2 {
92+
return errBufferTooSmall
93+
}
9194
m.CipherSuiteID = new(uint16)
9295
*m.CipherSuiteID = binary.BigEndian.Uint16(data[currOffset:])
9396
currOffset += 2
9497

95-
if len(data) < currOffset {
98+
if len(data) <= currOffset {
9699
return errBufferTooSmall
97100
}
98101
if compressionMethod, ok := protocol.CompressionMethods()[protocol.CompressionMethodID(data[currOffset])]; ok {

0 commit comments

Comments
 (0)