Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: explicitly use uint64 for payload length #1949

Merged
merged 2 commits into from
Jun 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gssapi_kerberos.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ 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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to change this to size > math.MaxInt32 rather than MaxUint32. Line 65 would panic on a 32-bit system if size is > math.MaxInt32. But, you are kinda asking for it if you are trying to write > 2GB of data all at once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I signed the CLA, btw, but can't comment on the PR for some reason. (Not sure I really needed to be the owner of such a small change :D, but thanks for including me.)

return 0, errors.New("payload too large, will overflow uint32")
Expand Down