Skip to content

Commit 7f0afe8

Browse files
authored
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.
1 parent beb7deb commit 7f0afe8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/libafl/src/corpus/inmemory_ondisk.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ impl<I> InMemoryOnDiskCorpus<I> {
490490
drop(fs::remove_file(lockfile_path));
491491
} else {
492492
lockfile.seek(SeekFrom::Start(0))?;
493-
lockfile.write_all(&(ctr.parse::<u32>()? - 1).to_le_bytes())?;
493+
lockfile.write_all((ctr.parse::<u32>()? - 1).to_string().as_bytes())?;
494494
return Ok(());
495495
}
496496
}

0 commit comments

Comments
 (0)