Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-escaped CStr #5324

Merged
merged 1 commit into from
May 1, 2024
Merged

Fix non-escaped CStr #5324

merged 1 commit into from
May 1, 2024

Conversation

rbran
Copy link
Contributor

@rbran rbran commented Apr 25, 2024

While running the code below, I noticed that binja would get possessed and output random strings:

use binaryninja::types::Type;
fn main() {
    binaryninja::headless::init();
    let my_type = Type::bool();
    let my_named_type = Type::named_type_from_type("MyName", &my_type);
    println!("my_named_type: |{my_named_type:?}|");
    binaryninja::headless::shutdown();
    println!("shutdown");
}

Output something like:

my_named_type: |typedef MyName
called `Result::unwrap()` on an `Err` valueBINJA_DIR/home/rbran/src/binaryninja-api/rust/src/headless.rsFailed to find libbinaryninjacore path!plugins;|
shutdown

On closer inspection, I noticed that was cause by this simple string being passed as Rust Str and not C Str, missing the null char.

@rbran rbran marked this pull request as ready for review April 25, 2024 12:57
@rssor rssor merged commit 96c1336 into Vector35:dev May 1, 2024
1 of 2 checks passed
@rbran rbran deleted the fix-non-escaped branch May 1, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants