Skip to content

Add Bounds Check #1

@jbuckmccready

Description

@jbuckmccready

Considering the context is python there should be bounds checks where appropriate to avoid undefined behavior in the CavalierContours library.

I think there is only one place that is missing the check when calling cavc_remove_range: https://github.com/proto3/cavaliercontours-python/blob/master/cavaliercontours/cavaliercontours.py#L174

if start_index < 0 or count < 0 or start_index + count > self.vertex_count():
    ...throw index out of range here...

I added checks that start_index and count are positive since I wasn't sure how it coerces to a uint32 if a negative value is given (it may wrap to a very large uint32, on the python docs it says no overflow checking is done for a c_uint: https://docs.python.org/3/library/ctypes.html).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions