Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rcvalle/rust-crate-sanitizers
FFI bindings for the sanitizers interfaces.
https://github.com/rcvalle/rust-crate-sanitizers
Last synced: about 1 month ago
JSON representation
FFI bindings for the sanitizers interfaces.
- Host: GitHub
- URL: https://github.com/rcvalle/rust-crate-sanitizers
- Owner: rcvalle
- License: apache-2.0
- Created: 2024-02-16T18:41:02.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-17T09:00:51.000Z (about 1 month ago)
- Last Synced: 2024-11-17T09:15:18.025Z (about 1 month ago)
- Language: Rust
- Homepage:
- Size: 191 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
sanitizers
==========![Build Status](https://github.com/rcvalle/rust-crate-sanitizers/workflows/build/badge.svg)
Interfaces and FFI bindings for the
[sanitizers](https://github.com/google/sanitizers) interfaces.Installation
------------To install the `sanitizers` crate:
1. On a command prompt or terminal with your package root's directory as the
current working directory, run the following command:cargo add sanitizers
Or:
1. Add the `sanitizers` crate to your package root's `Cargo.toml` file and
replace `X.Y.Z` by the version you want to install:[dependencies]
sanitizers = "X.Y.Z"2. On a command prompt or terminal with your package root's directory as the
current working directory, run the following command:cargo fetch
Usage
-----To use the `sanitizers` crate:
1. Import the sanitizer module or funtions from the `sanitizers` crate. E.g.:
use sanitizers::asan::*;
2. Use the provided interface for the sanitizer. E.g.:
...
let mut data = vec![0u8; 100];
let data_ptr = data.as_mut_ptr() as *const c_void;// Poison the memory region
unsafe {
__asan_poison_memory_region(data_ptr, data.len());
}// Check if the memory region is poisoned
let is_poisoned = unsafe { __asan_address_is_poisoned(data_ptr) };
assert_eq!(is_poisoned, 1);
...3. Build your package with the sanitizer enabled. It is recommended to rebuild
the standard library with the sanitizer enabled by using the Cargo build-std
feature (i.e., `-Zbuild-std`) when enabling the sanitizer. E.g.:RUSTFLAGS="-Clinker=clang -Clink-arg=-fuse-ld=lld -Zsanitizer=address" \
cargo build -Zbuild-std -Zbuild-std-features \
--target x86_64-unknown-linux-gnuContributing
------------See [CONTRIBUTING.md](CONTRIBUTING.md).
License
-------Licensed under the Apache License, Version 2.0 or the MIT License. See
[LICENSE-APACHE](LICENSE-APACHE) or [LICENSE-MIT](LICENSE-MIT) for license text
and copyright information.