Skip to content

Validate face buffer of subdivision meshes - #631

Open
stefanatwork wants to merge 1 commit into
masterfrom
fix/subdiv-face-valence-validation
Open

stefanatwork wants to merge 1 commit into
masterfrom
fix/subdiv-face-valence-validation

Conversation

@stefanatwork

Copy link
Copy Markdown
Collaborator

The half edge of a face is looked up through the prefix sum of the face valences stored in the face buffer, but this buffer was never validated.

A face with zero vertices produced a start offset that pointed behind the half edge array, thus dereferencing the half edge of such a face during commit read out of bounds. A face buffer whose valences sum up to more than the size of an index buffer caused the half edge array, which is sized through the index buffer, to get written out of bounds. The sum was further accumulated in 32 bit, thus it could also wrap around.

The face buffer now gets validated before the half edge structures are built, and inconsistent face and index buffers raise an RTC_ERROR_INVALID_OPERATION error. The check is performed before any state is updated, thus a rejected geometry is left unmodified.

The half edge of a face is looked up through the prefix sum of the face
valences stored in the face buffer, but this buffer was never validated.

A face with zero vertices produced a start offset that pointed behind the
half edge array, thus dereferencing the half edge of such a face during
commit read out of bounds. A face buffer whose valences sum up to more
than the size of an index buffer caused the half edge array, which is
sized through the index buffer, to get written out of bounds. The sum was
further accumulated in 32 bit, thus it could also wrap around.

The face buffer now gets validated before the half edge structures are
built, and inconsistent face and index buffers raise an
RTC_ERROR_INVALID_OPERATION error. The check is performed before any
state is updated, thus a rejected geometry is left unmodified.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
However, the indices of the topologies themselves may be different.

The face buffer has to be consistent with the index buffers, thus each
face must have at least 3 vertices and the sum of all face vertex

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we handle the special cases of 0,1,2 vertices correctly? These probably get already filtered out correctly. We just need to check that index array is properly sized.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the code just filters these out, we should keep that behavior.

halfEdges.resize(mesh->numEdges());

/* the index buffer of each topology has to be large enough for all half edges */
if (vertexIndices.size() < mesh->numHalfEdges)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check should be all that is needed

However, the indices of the topologies themselves may be different.

The face buffer has to be consistent with the index buffers, thus each
face must have at least 3 vertices and the sum of all face vertex

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently the code just filters these out, we should keep that behavior.

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.

2 participants