From 376eedbaf2903e0ce7f37b3d40514733eccf6527 Mon Sep 17 00:00:00 2001 From: dergoegge Date: Thu, 26 Jun 2025 14:35:29 +0100 Subject: [PATCH] libafl: fix lockfile ctr serialization All locations reading from the lockfile expect an integer as a string, but in `InMemoryOnDiskCorpus::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::save_testcase` during parsing of the file's contents. Fix this by writing the integer to the lockfile as a string in `InMemoryOnDiskCorpus::remove_testcase` as well. --- crates/libafl/src/corpus/inmemory_ondisk.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/libafl/src/corpus/inmemory_ondisk.rs b/crates/libafl/src/corpus/inmemory_ondisk.rs index 00e598bb86..d5432a765c 100644 --- a/crates/libafl/src/corpus/inmemory_ondisk.rs +++ b/crates/libafl/src/corpus/inmemory_ondisk.rs @@ -490,7 +490,7 @@ impl InMemoryOnDiskCorpus { drop(fs::remove_file(lockfile_path)); } else { lockfile.seek(SeekFrom::Start(0))?; - lockfile.write_all(&(ctr.parse::()? - 1).to_le_bytes())?; + lockfile.write_all((ctr.parse::()? - 1).to_string().as_bytes())?; return Ok(()); } }