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 panic in mmap shmem when full_file_name is less than MAX_MMAP_FILENAME_LEN #2536

Merged
merged 4 commits into from
Sep 24, 2024

Conversation

andreafioraldi
Copy link
Member

This PR fix this panic on macOS:

thread '<unnamed>' panicked at /Users/jeremie/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libafl_bolts-0.13.2/src/shmem.rs:695:68:
range end index 20 out of range for slice of length 19

@domenukk
Copy link
Member

error: this expression creates a reference which is immediately dereferenced by the compiler
   --> libafl_bolts/src/shmem.rs:700:51
    |
700 |                     filename_path.copy_from_slice(&full_file_name.as_bytes());
    |                                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: change this to: `full_file_name.as_bytes()`

filename_path
.copy_from_slice(&full_file_name.as_bytes()[..MAX_MMAP_FILENAME_LEN]);
filename_path[0..full_file_name.len()]
.copy_from_slice(full_file_name.as_bytes());
filename_path[MAX_MMAP_FILENAME_LEN - 1] = 0; // Null terminate!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should now be be full_file_name.len() right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed (I think)

@domenukk domenukk merged commit 7289379 into main Sep 24, 2024
21 of 22 checks passed
@domenukk domenukk deleted the fix_mmap_shmem branch September 24, 2024 01:37
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