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.
Affected packages
| Ecosystem | Package | Affected | Fixed | Record |
|---|---|---|---|---|
| crates.io | orx-pinned-vec | < 3.21.0 | 3.21.0 | GHSA-h5j3-crg5-8jqm |
| crates.io | orx-pinned-vec | >= 0.0.0-0, < 3.21.0 | 3.21.0 | RUSTSEC-2025-0106 |
References
- https://github.com/orxfun/orx-pinned-vec/issues/52 web
- https://github.com/orxfun/orx-pinned-vec/pull/53 web
- https://github.com/orxfun/orx-pinned-vec/commit/4a4007a1aaff25cd417853c76163883a7110e276 web
- https://github.com/orxfun/orx-pinned-vec package
- https://rustsec.org/advisories/RUSTSEC-2025-0106.html web