cve-rs 0.7.0

Blazingly fast memory vulnerabilities, written in 100% safe Rust.
Documentation
//! A 100% memory-safe segmentation fault.
//!
//! We first use the soundness hole (and our transmute implementation) to create a mutable null reference to a `u8`.
//! Then, we dereference it to get a segmentation fault!

/// Segfaults the program.
///
/// See [`crate::transmute()`]
pub fn segfault() -> ! {
	let null = crate::null_mut::<u8>();
	*null = 42;

	// If null doesn't work, try max. Surely that'll stop it.
	// Confirmed to be effective on WASM.
	let max = crate::not_alloc::<u8>();
	*max = 69;

	unreachable!("Sorry, your platform is too strong.")
}

#[cfg(test)]
mod tests {
	#[test]
	fn test_segfault() {
		use std::process::Command;
		let output = Command::new("cargo")
			.arg("run")
			.arg("segfault")
			.output()
			.unwrap();

		if output.status.success()
			|| std::str::from_utf8(&output.stderr)
				.unwrap()
				.contains("Sorry, your platform is too strong.")
		{
			panic!("Segfault failed to segfault");
		}
	}
}