Repository navigation
fix(encodings): refuse Base45 and Base85 groups that overflow - #50
Merged
Merged
Conversation
From Base45 checked the range of a three-digit group but not a two-digit one, so 'ZZ' (1610) came out as the single byte 0x4a. From Base85 never checked its groups, so 's8W-"' (2^32) decoded to four zero bytes and 'uuuuu' to arbitrary bytes. Both now raise the same out-of-range error instead of wrapping the value.
Collaborator
|
Thank you for your contribution and for taking the time to improve DecodeBox. Really appreciate your work! |
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.
What this changes
From Base45 checks that a three-digit group fits in two bytes, but a two-digit group was pushed as is, so
ZZ(1610) silently came out as the byte0x4a(RFC 9285 says a two-digit group above 255 is invalid). From Base85 had no range check at all, sos8W-"(2^32) decoded to00 00 00 00anduuuuuto arbitrary bytes. Both decoders now raise the same "group is out of range" error instead of wrapping the value. Full and padded final Base85 groups are checked, for every alphabet.Related issue
none
How it was tested
New cases in
operations.verified.test.tsnext to the other Base45 edge cases: the largest valid groups still decode (U5toff,s8W-!toffffffff), andZZ,BB8::,s8W-",uuuuu,uuuand Z85%%%%%are refused. Both tests fail on main.Locally on Node 24 and Node 22:
npm run lint,npm run typecheck,npm run test -- --run(1271 passed),npm run buildandnpm run check:sdk-dist, plus the CI Chrome load check and the GraalJS Java provider checks.Checklist
npm run lint,npm run typecheck,npm run testandnpm run buildall pass locallyanyintroduced in application codeeval,new Function,dangerouslySetInnerHTML, orinnerHTMLassignment