Repository navigation
fix(stdlib): enforce max_string_bytes in print, string.char, utf8.char and debug.traceback - #440
Open
davydog187 wants to merge 1 commit into
Open
davydog187 wants to merge 1 commit into
davydog187 wants to merge 1 commit into
Conversation
…r and debug.traceback print joined all of its arguments with no check, so a script could make one write far past the ceiling. It now counts the line as it assembles it and raises before writing. string.char, utf8.char and debug.traceback refuse an oversized result before building it. string.format no longer pre-checks a conversion's width, which restores the bad-argument error order under a ceiling smaller than the width at a cost of at most 99 bytes. The max_string_bytes option doc now names what the ceiling does not bound (the error() position prefix, one in-flight format piece).
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.
Follow-up to #426.
printcounted nothing: 64 references to a 1 MiB string made one 67 MB write at a 1 MiB ceiling. It now tracks the line size as it assembles it and raises "resulting string too large" before writing (0 bytes written in the probe).string.char,utf8.charanddebug.tracebackrefuse an oversized result before building it (traceback per frame, so a deep stack is refused early).error()position prefix: documented, not fixed. The message was already within the ceiling and the prefix is chunk name plus a few bytes, constant, not growing with arguments or frames; refusing would replace the user's error with a size error.string.format: dropped the width pre-check (andpadded_width/1), so a bad argument reports its own error under a tiny ceiling; costs at most 99 bytes. This also removes the displaced comment block.:max_string_bytesdoc no longer says "any single string" and lists what it does not bound.Tests: new
test/lua/vm/builder_ceiling_test.exs(red before, green after). Full suite: 2779 tests; one BootstrapTest flake on one run, which passes alone and on re-run.