Skip to content

Commit e7e4679

Browse files
committed
Fuzz the hasher object to include the invalid state
1 parent f71fdee commit e7e4679

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

fuzzing/fuzz_md5.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size
2727
std::span data_span {c_data, size};
2828
boost::crypt::md5(data_span);
2929
#endif
30+
31+
// Fuzz the hasher object
32+
boost::crypt::md5_hasher hasher;
33+
hasher.process_bytes(data, size);
34+
hasher.process_bytes(data, size);
35+
hasher.process_bytes(data, size);
36+
hasher.get_digest();
37+
hasher.process_bytes(data, size); // State is invalid but should not crash
3038
}
3139
catch(...)
3240
{

fuzzing/fuzz_sha1.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size
2727
std::span data_span {c_data, size};
2828
boost::crypt::sha1(data_span);
2929
#endif
30+
31+
// Fuzz the hasher object
32+
boost::crypt::sha1_hasher hasher;
33+
hasher.process_bytes(data, size);
34+
hasher.process_bytes(data, size);
35+
hasher.process_bytes(data, size);
36+
hasher.get_digest();
37+
hasher.process_bytes(data, size); // State is invalid but should not crash
3038
}
3139
catch(...)
3240
{

0 commit comments

Comments
 (0)