Skip to content

Commit ad1d7e7

Browse files
committed
init
1 parent dcb888c commit ad1d7e7

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
```toml
2+
[advisory]
3+
id = "RUSTSEC-0000-0000"
4+
package = "scanner-rs"
5+
date = "2025-03-27"
6+
informational = "unsound"
7+
categories = ["memory-corruption"]
8+
keywords = ["out-of-bounds read"]
9+
```
10+
11+
```rust
12+
/// Represents a pattern match.
13+
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
14+
pub struct Match<'a> {
15+
/// Haystack the match was found in.
16+
pub haystack: &'a [u8],
17+
/// Offset in the haystack the match was found.
18+
pub at: u32,
19+
/// Stored offsets as specified in the pattern.
20+
pub store: [u32; MAX_STORE],
21+
}
22+
23+
impl<'a> Match<'a> {
24+
/// Get the pointer to the location that was matched.
25+
#[inline]
26+
pub fn ptr(&self) -> *const u8 {
27+
unsafe { self.haystack.as_ptr().offset(self.at as isize) }
28+
}
29+
/// Get a pointer from the store array.
30+
#[inline]
31+
pub fn get<T>(&self, idx: usize) -> *const T {
32+
unsafe { self.haystack.as_ptr().offset(self.store[idx] as isize) as *const T }
33+
}
34+
}
35+
```
36+
37+
This crate allow users to create out of bound issue by using merely safe api (Ex. `Match.get`).

0 commit comments

Comments
 (0)