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

Conversation

s1341
Copy link
Collaborator

@s1341 s1341 commented Dec 24, 2024

This is necessary if you want to disable locking for a corpus.

}
} 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.

@domenukk
Copy link
Member

Feel free to merge. As stated elsewhere, #2434 would be the proper fix, though :)

@domenukk domenukk merged commit 9b4cd51 into main Dec 24, 2024
102 of 103 checks passed
@domenukk domenukk deleted the dont_fail_write_when_locking_disabled branch December 24, 2024 13:22
riesentoaster pushed a commit to riesentoaster/LibAFL that referenced this pull request Dec 24, 2024
…s disabled (AFLplusplus#2791)

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

* fmt

* inmemory_ondisk: Add a log message on failure

* clippy'

* micro optimization
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