From e80612655e1fa3de3dbc8e3463bedcab957610d1 Mon Sep 17 00:00:00 2001 From: Travis Bischel Date: Fri, 26 Feb 2021 18:18:44 -0700 Subject: [PATCH] broker: shift sizeBuf 1 left by 8 for guessing tls version 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 --- pkg/kgo/broker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kgo/broker.go b/pkg/kgo/broker.go index 0e6866c4..f876f9ed 100644 --- a/pkg/kgo/broker.go +++ b/pkg/kgo/broker.go @@ -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 {