Skip to content

Commit

Permalink
add poc for switch int
Browse files Browse the repository at this point in the history
  • Loading branch information
VaynNecol committed Jan 3, 2025
1 parent 1f02827 commit 8954d2c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/support/uaf/uaf_swithint/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "uaf_swithint"
version = "0.1.0"
edition = "2021"

[dependencies]
33 changes: 33 additions & 0 deletions tests/support/uaf/uaf_swithint/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use std::mem::ManuallyDrop;
enum A {
A1,
A2
}
fn evil_test(a: A) {
let mut count = 0;
let mut slot = ManuallyDrop::<Box<u8>>::new(Box::new(1));
loop {
if let A::A1 = a {
count += 1;
if count < 2 {
unsafe {
ManuallyDrop::drop(&mut slot);
}
continue;
}
break;
} else {
println!("{:?}", slot);
unsafe {
ManuallyDrop::drop(&mut slot);
}
break;
}
}
}
fn main() {
let a1 = A::A1;
let a2 = A::A2;
evil_test(a1);
evil_test(a2);
}

0 comments on commit 8954d2c

Please sign in to comment.