Source file: crypto/tls/handshake_messages.go
Function: func (m *clientHelloMsg) unmarshal(data []byte) bool {...}
Code fragment:
switch extension {
case extensionServerName:
if length < 2 {
return false
}
numNames := int(data[0])<<8 | int(data[1])
d := data[2:]
for i := 0; i < numNames; i++ {
...
In this fragment during processing SNI extension the ServerNameListLength field is processed as a count of list elements (variable numNames). But this field contains the size of list in bytes (tested in wireshark with TLS 1.2).
This code will work in case SNI contains only one element with type HostName in the list, otherwise the handshake will fail.
Source file: crypto/tls/handshake_messages.go
Function:
func (m *clientHelloMsg) unmarshal(data []byte) bool {...}Code fragment:
In this fragment during processing SNI extension the ServerNameListLength field is processed as a count of list elements (variable numNames). But this field contains the size of list in bytes (tested in wireshark with TLS 1.2).
This code will work in case SNI contains only one element with type HostName in the list, otherwise the handshake will fail.