Repository navigation
Conversation
vxc reads a .vxlib in place of the .vx file beside it. An empty .vxlib made vxc panic in gid.rs, because the decoder sliced the file without checking its length. Now the decoder checks each read: the header, each count, and how deep a type nests. vxc decodes the whole file when an import or --link-interface finds it. So an empty, cut, stale or garbled file is an error that names the file and says to remove or rewrite it. Fixes: #4600
This branch has not been deployed
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.
Stacked on #4619. The change does not need #4619, but #4624 (the fix for #4599) needs both, and a stack is one line.
vxc reads a
.vxlibfile in place of the.vxfile beside it. An empty.vxlibmade vxc panic ingid.rs, because the decoder sliced the file without checking its length. Other broken files could panic or overflow the stack too.What changed
The decoder checks each read:
Vec::with_capacitypanic.The new
read_interface_filedecodes the whole file when an import or--link-interfacefinds it. A broken file gives this error:Tests
a_broken_file_is_an_errorinsrc/metadata.rs: an empty file, a header count or a body count that is too large, and a deep type (100,000 levels).tests/frontend/fail/a_broken_vxlib_file_is_an_error_that_names_it.vx: an empty file, a cut file, a file with the wrong version stamp, a plain text file, and a whole file that runs.The pre-commit hook passed on the top of the stack: #4619, this PR and #4624 on main.
Not covered
The decoder checks the format of a file, not that each function body in it is well formed. A body with a changed byte can still make vxc panic later. See #4622.
Fixes #4600