-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path0131-rocket_http.rs
56 lines (45 loc) · 1.25 KB
/
0131-rocket_http.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
47
48
49
50
51
52
53
54
55
56
/*!
```rudra-poc
[target]
crate = "rocket_http"
version = "0.4.6"
indexed_version = "0.4.5"
[test]
cargo_toolchain = "nightly"
[report]
issue_url = "https://github.com/SergioBenitez/Rocket/issues/1534"
issue_date = 2021-02-09
rustsec_url = "https://github.com/RustSec/advisory-db/pull/834"
rustsec_id = "RUSTSEC-2021-0044"
[[bugs]]
analyzer = "UnsafeDataflow"
bug_class = "PanicSafety"
rudra_report_locations = ["src/uri/formatter.rs:334:5: 357:6"]
```
!*/
#![forbid(unsafe_code)]
use rocket_http::uri::{Formatter, Query, UriDisplay};
struct MyDisplay;
struct MyValue;
impl UriDisplay<Query> for MyValue {
fn fmt(&self, _f: &mut Formatter<Query>) -> std::fmt::Result {
panic!()
}
}
struct Wrapper<'a, 'b>(&'a mut Formatter<'b, Query>);
impl UriDisplay<Query> for MyDisplay {
fn fmt(&self, formatter: &mut Formatter<Query>) -> std::fmt::Result {
let wrapper = Wrapper(formatter);
let temporary_string = String::from("hello");
wrapper.0.write_named_value(&temporary_string, MyValue)
}
}
impl<'a, 'b> Drop for Wrapper<'a, 'b> {
fn drop(&mut self) {
let _overlap = String::from("12345");
self.0.write_raw("world").ok();
}
}
fn main() {
println!("{}", &MyDisplay as &dyn UriDisplay<Query>);
}