Repository navigation
Conversation
- SnbtParser: cap nesting at 512 levels so deep input is a parse error instead of a StackOverflowError that tryParse did not catch; keep out-of-range typed numbers (999b) as text instead of throwing NumberFormatException. - InventoryStringParser: replace the quadratic slot-overlap check with a BitSet, drop duplicate slots when expanding ranges, and report malformed numbers as GeneratorException. - GeneratorCacheKey: length-prefix short values and tag hashed ones so a value containing ';name=' or spelling a hash cannot collide with another configuration.
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.
Why
Follow-up to the security review (see #116). Three smaller issues in code that handles untrusted text.
What changed
SnbtParser{a:[[[[…with a few thousand brackets overflowed the stack, andtryParseonly caughtException, so theStackOverflowErrorescaped. It is now anNbtParseException.999b,99999s) stays an unquoted string instead of throwing a rawNumberFormatException.InventoryStringParserBitSet; behaviour is the same (the later item wins shared slots).[1-54,1-54,…]no longer expands to many times the input length.{slot:amount}maps are reported asGeneratorExceptioninstead ofNumberFormatException.GeneratorCacheKeylore="x;name=y", name="z"andlore="x", name="y;name=z"flattened to the same string, and a 64-character value equal to another value's SHA-256 collided with it, so one configuration could be served another's cached image. The cache is in memory only, so the changed key format needs no migration.Testing
SnbtParserLimitsTest(4) andGeneratorCacheKeyTest(3); three tests added toInventoryStringParserTest.