Skip to content

Conversation

dergoegge
Copy link
Contributor

I'm not entirely sure what the purpose of the lockfiles is but I ran into the following crash with my fuzzer:

called `Result::unwrap()` on an `Err` value: Unknown("Failed to parse Int: ParseIntError { kind: InvalidDigit }",    0: <libafl_bolts::Error as core::convert::From<core::num::error::ParseIntError>>::from
   1: libafl::corpus::inmemory_ondisk::InMemoryOnDiskCorpus<I>::save_testcase
   2: <libafl::corpus::inmemory_ondisk::InMemoryOnDiskCorpus<I> as libafl::corpus::Corpus<I>>::add
   3: <libafl::fuzzer::StdFuzzer<CS,F,IF,OF> as libafl::fuzzer::ExecutionProcessor<EM,I,OT,S>>::evaluate_execution
   4: <libafl::fuzzer::StdFuzzer<CS,F,IF,OF> as libafl::fuzzer::Fuzzer<E,EM,I,S,ST>>::fuzz_one

After looking at how data is written to and read from the lockfile, it appears to expect an integer as a string when reading but in InMemoryOnDiskCorpus<I>::remove_testcase it writes the raw bytes of the integer to the file. See the commit message for further explanation.

All locations reading from the lockfile expect an integer as a string,
but in `InMemoryOnDiskCorpus<I>::remove_testcase` the raw bytes of the
integer are written to the file in little endian byte order.

This may cause "ParseIntError { kind: InvalidDigit }" in e.g.
`InMemoryOnDiskCorpus<I>::save_testcase` during parsing of the file's
contents.

Fix this by writing the integer to the lockfile as a string in
`InMemoryOnDiskCorpus<I>::remove_testcase` as well.
@tokatoka
Copy link
Member

the original code is 💩
we plan to wipe everything out in #3159.

but thank you this would be a quick fix meanwhile 👍

@tokatoka tokatoka merged commit 7f0afe8 into AFLplusplus:main Jun 26, 2025
108 checks passed
ThomasTNO pushed a commit to ThomasTNO/LibAFL that referenced this pull request Aug 22, 2025
All locations reading from the lockfile expect an integer as a string,
but in `InMemoryOnDiskCorpus<I>::remove_testcase` the raw bytes of the
integer are written to the file in little endian byte order.

This may cause "ParseIntError { kind: InvalidDigit }" in e.g.
`InMemoryOnDiskCorpus<I>::save_testcase` during parsing of the file's
contents.

Fix this by writing the integer to the lockfile as a string in
`InMemoryOnDiskCorpus<I>::remove_testcase` as well.
tokatoka pushed a commit that referenced this pull request Aug 25, 2025
* Fix removing file with ctr of the form "\u{3}000"

* Ensure input is loaded, also ensure exec_time is set

* Clippy

* Revert "Fix removing file with ctr of the form "\u{3}000""

This reverts commit 4cb3507.

* libafl: fix lockfile ctr serialization (#3319)

All locations reading from the lockfile expect an integer as a string,
but in `InMemoryOnDiskCorpus<I>::remove_testcase` the raw bytes of the
integer are written to the file in little endian byte order.

This may cause "ParseIntError { kind: InvalidDigit }" in e.g.
`InMemoryOnDiskCorpus<I>::save_testcase` during parsing of the file's
contents.

Fix this by writing the integer to the lockfile as a string in
`InMemoryOnDiskCorpus<I>::remove_testcase` as well.

* Extract run target with timing

* Expose run_target_with_timing

* Simplify

* HasExecutions

* clippy

* linters

* fmt

---------

Co-authored-by: Niklas Gögge <[email protected]>
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