orxfun/orx-pinned-vec · Security
orx-pinned-vec has undefined behavior in index_of_ptr with empty slices
- GHSA ID
- GHSA-h5j3-crg5-8jqm
- Severity
- low
- Published
- Updated
- CVSS v4
- 2 · CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:P
Description
The safe function index_of_ptr causes undefined behavior when called with an empty slice.
The issue occurs in the line ptr.add(slice.len() - 1) which underflows when slice.len() is 0, creating a pointer with a massive offset. According to Rust's safety rules, creating such a pointer causes immediate undefined behavior.
CWEs
- CWE-119 · Improper Restriction of Operations within the Bounds of a Memory Buffer
- CWE-191 · Integer Underflow (Wrap or Wraparound)