Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer overrun if header specifies more vertices than the file really has #54

Open
wants to merge 1 commit into
base: 2.4
Choose a base branch
from

Conversation

RamonArguelles
Copy link
Contributor

As discussed in here:

There is a buffer overrun when parsing a PLY with a header that specifies more vertices than what the file really has. Aka, if the header says there are 20 vertices, but the contents only have 19, you'll hit the problem.

Looking a little bit into the code, tinyply already uses the information from the header to allocate a buffer that should fit the file contents. The size of the buffer is thus known, but it is not passed all the way down. This PR implements a simple fix that mainly passes the buffer size a couple of frames down into the stack, when we are about to read from the file and copy into the buffer. If we pass the buffer size down, we can check if the copy is going to fit, and if not, throw an exception instead of attempting to reference beyond the buffer.

We tested our local fix with both master and 2.4 branches, and it does seem to work in both cases.

This PR is for the 2.4 branch. Another alternative, though, is to complete the PR into master first, and then merge master into the 2.4 branch (dealing with the merge conflicts at that point)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant