mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-11-21 15:30:59 +00:00
example to trigger Cosmopolitan's ASAN runtime
This commit is contained in:
parent
2561dec542
commit
298b7453c2
1 changed files with 27 additions and 0 deletions
27
src/bin/unsafe-but-asan.rs
Normal file
27
src/bin/unsafe-but-asan.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
#![no_main]
|
||||
#![no_std]
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate libc;
|
||||
|
||||
extern "C" {
|
||||
fn ShowCrashReports();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn main(_argc: isize, _argv: *const *const u8) -> isize {
|
||||
unsafe {
|
||||
ShowCrashReports();
|
||||
let mut buffer = libc::malloc(13);
|
||||
const c_str: &'static str = "Hello\0";
|
||||
libc::strcpy(buffer as *mut i8, c_str.as_ptr() as *const i8);
|
||||
libc::free(buffer);
|
||||
libc::printf(buffer as *const _);
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
#[panic_handler]
|
||||
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
Loading…
Reference in a new issue