-
Notifications
You must be signed in to change notification settings - Fork 4
/
0090-endian.rs
46 lines (41 loc) · 982 Bytes
/
0090-endian.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*!
```rudra-poc
[target]
crate = "endian_trait"
version = "0.6.0"
[report]
issue_url = "https://gitlab.com/myrrlyn/endian_trait/-/issues/1"
issue_date = 2021-01-04
rustsec_url = "https://github.com/RustSec/advisory-db/pull/814"
rustsec_id = "RUSTSEC-2021-0039"
[[bugs]]
analyzer = "UnsafeDataflow"
bug_class = "PanicSafety"
bug_count = 4
rudra_report_locations = ["src/slices.rs:9:2: 14:3", "src/slices.rs:15:2: 20:3", "src/slices.rs:21:2: 26:3", "src/slices.rs:27:2: 32:3"]
```
!*/
#![forbid(unsafe_code)]
use endian_trait::Endian;
#[derive(Debug)]
struct Foo(Box<Option<i32>>);
impl Endian for Foo {
fn to_be(self) -> Self {
println!("PANIC BY MISTAKE {}", self.0.as_ref().as_ref().unwrap());
self
}
fn to_le(self) -> Self {
self
}
fn from_be(self) -> Self {
self
}
fn from_le(self) -> Self {
self
}
}
fn main() {
let mut foo = [Foo(Box::new(None))];
let x = (&mut foo).to_be();
dbg!(x);
}