ptex: More comprehensive valid_file and validation of header#5265
Open
lgritz wants to merge 2 commits into
Open
ptex: More comprehensive valid_file and validation of header#5265lgritz wants to merge 2 commits into
lgritz wants to merge 2 commits into
Conversation
Signed-off-by: Larry Gritz <lg@larrygritz.com>
Previously, our PtexInput::valid_file() only checked that the first 4 bytes were "PTEX", and the open() method just directly called PtexTexture::open(), which is really bad with validity checks and can crash or OOM with corrupted files. But Ptex has a fixed 64 byte header (cheap to read and inspect) that has lots of fields that let us more accurately check for reasonable file validity. Therefore, we both beef up valid_file, and also have open() do these checks (rejecting many forms of corruption) before turning the job over to the Ptex library itself. Signed-off-by: Larry Gritz <lg@larrygritz.com>
Collaborator
Author
|
Amended with a much more comprehensive approach, and updated the title and description. |
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.
Previously, we did not have a PtexInput::valid_file() method, and our open() method just directly called PtexTexture::open(), which is really bad with validity checks and can crash or OOM with corrupted files.
But Ptex has a fixed 64 byte header (cheap to read and inspect) that has lots of fields that let us more accurately check for reasonable file validity. Therefore, we both implement valid_file, and also have open() do these checks (rejecting many forms of corruption) before turning the job over to the Ptex library itself.
Assisted-by: Claude Code / opus-4.8