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

imemory_ondisk: Don't fail write under any circumstances if locking is disabled #2791

Merged
merged 5 commits into from
Dec 24, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion libafl/src/corpus/inmemory_ondisk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,14 @@ impl<I> InMemoryOnDiskCorpus<I> {
*testcase.metadata_path_mut() = Some(metafile_path);
}

self.store_input_from(testcase)?;
if self.locking {
self.store_input_from(testcase)?;
} else if let Err(error) = self.store_input_from(testcase) {
log::error!(
"An error occurred when trying to write a testcase without locking: {}",
Copy link
Member

Choose a reason for hiding this comment

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

This is like a format string, right? So we can do
"An error occurred when trying to write a testcase without locking: {err}",

Copy link
Member

Choose a reason for hiding this comment

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

Micro optimization, but the whole thing could be

if let Err(err) = self.store_input_from(testcase) {
   if self.locking {
       return Err(err);
   }
   log::error!("An error occurred when trying to write a testcase without locking: {err}",
}

then you only need to check the extra condition in the error case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

applied.

error
);
}
Ok(())
}

Expand Down
Loading