Skip to content

crypto/tls: Server Name Indication. ServerNameListLength field contains length of list in bytes #10793

Description

@v-lavrentikov

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions