fix: increase byte array length limit for 1.7.x clients in WriteBytes17#558
Merged
Merged
Conversation
Issue #533 reported that 1.7.x clients fail to login with error: 'Cannot write byte array longer than 127 (got 162 bytes)' The problem was in WriteBytes17() function which was checking against math.MaxInt8 (127) for non-extended mode, but should check against math.MaxInt16 (32767) to match Velocity's behavior. This change: - Updates WriteBytes17 to use math.MaxInt16 limit for allowExtended=false - Matches Velocity's ProtocolUtils.writeByteArray17 implementation - Fixes 1.7.x login failures caused by RSA public key size (~162 bytes) - Adds comprehensive tests including the specific 162-byte case from #533 Fixes #533
Deploying gate-minekube with
|
| Latest commit: |
fefc1f5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ce22e658.gate-minekube.pages.dev |
| Branch Preview URL: | https://fix-1-7-x-login-byte-array-l.gate-minekube.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Issue #533 reported that 1.7.x clients fail to login with the error:
Cannot write byte array longer than 127 (got 162 bytes)This affects basic connectivity for 1.7.x Minecraft clients, preventing them from logging into the proxy.
Fixes #533
Root Cause
The
WriteBytes17()function inpkg/edition/java/proto/util/writer.gowas checking byte array length againstmath.MaxInt8(127) whenallowExtended=false, but this limit is too restrictive for 1.7.x encryption requests.RSA public keys used in encryption requests are typically ~162 bytes in DER format, which exceeds the 127-byte limit.
Solution
Updated
WriteBytes17()to usemath.MaxInt16(32767) instead ofmath.MaxInt8(127) for non-extended mode, matching Velocity's behavior.Reference: Velocity's
ProtocolUtils.writeByteArray17()usesShort.MAX_VALUE(32767) whenallowExtended=false.Changes
writer.go: Changed limit frommath.MaxInt8tomath.MaxInt16writer_test.go: Added comprehensive tests including:Testing
✅ All new tests pass
✅ Existing proto package tests pass
✅ Project builds successfully
✅ Specific test case for 162-byte array (from #533) now works
Verification
The fix specifically addresses the case where:
WriteBytes17(publicKey, false)is calledThis change maintains backward compatibility while fixing 1.7.x client login issues.