Skip to content

Commit

Permalink
broker: shift sizeBuf 1 left by 8 for guessing tls version
Browse files Browse the repository at this point in the history
As done in crypto/tls conn.go line 629 in go1.16,

         vers := uint16(hdr[1])<<8 | uint16(hdr[2])

It was a bug to miss the shift
  • Loading branch information
twmb committed Feb 27, 2021
1 parent cd5e7fe commit e806126
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/kgo/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ func (cxn *brokerCxn) parseReadSize(sizeBuf []byte) (int32, error) {
// following, where all major versions are 03xx. We
// look for an alert and major version byte to suspect
// if this we received a TLS alert.
tlsVersion := uint16(sizeBuf[1]) | uint16(sizeBuf[2])
tlsVersion := uint16(sizeBuf[1])<<8 | uint16(sizeBuf[2])
if sizeBuf[0] == 21 && tlsVersion&0x0300 != 0 {
versionGuess := fmt.Sprintf("unknown TLS version (hex %x)", tlsVersion)
for _, guess := range []struct {
Expand Down

0 comments on commit e806126

Please sign in to comment.