Skip to content

Commit

Permalink
Merge pull request #1949 from Shopify/dnwe/32bit
Browse files Browse the repository at this point in the history
fix: explicitly use uint64 for payload length
  • Loading branch information
dnwe authored Jun 2, 2021
2 parents 83d633e + a51d20a commit fca0631
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gssapi_kerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ type KerberosClient interface {

// writePackage appends length in big endian before the payload, and sends it to kafka
func (krbAuth *GSSAPIKerberosAuth) writePackage(broker *Broker, payload []byte) (int, error) {
length := len(payload)
length := uint64(len(payload))
size := length + 4 // 4 byte length header + payload
if size > math.MaxUint32 {
return 0, errors.New("payload too large, will overflow uint32")
if size > math.MaxInt32 {
return 0, errors.New("payload too large, will overflow int32")
}
finalPackage := make([]byte, size)
copy(finalPackage[4:], payload)
Expand Down

0 comments on commit fca0631

Please sign in to comment.