Skip to content

ptex: More comprehensive valid_file and validation of header#5265

Open
lgritz wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
lgritz:lg-ptexvalid
Open

ptex: More comprehensive valid_file and validation of header#5265
lgritz wants to merge 2 commits into
AcademySoftwareFoundation:mainfrom
lgritz:lg-ptexvalid

Conversation

@lgritz

@lgritz lgritz commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

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

lgritz added 2 commits June 27, 2026 17:46
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>
@lgritz lgritz changed the title ptex: add a valid_file method that checks the magic number ptex: More comprehensive valid_file and validation of header Jun 28, 2026
@lgritz

lgritz commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator Author

Amended with a much more comprehensive approach, and updated the title and description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant