code format

This commit is contained in:
vanhauser-thc
2025-04-10 09:30:18 +02:00
parent c71d487a4c
commit 6cbe58ff55
3 changed files with 20 additions and 7 deletions

View File

@ -7,8 +7,8 @@
#define _AFL_INTSIZEVAR u32 #define _AFL_INTSIZEVAR u32
u32 skim(const u32 *virgin, const u32 *current, const u32 *current_end); u32 skim(const u32 *virgin, const u32 *current, const u32 *current_end);
u32 classify_word(u32 word); u32 classify_word(u32 word);
inline u32 classify_word(u32 word) { inline u32 classify_word(u32 word) {
@ -52,8 +52,9 @@ void simplify_trace(afl_state_t *afl, u8 *bytes) {
} }
inline void classify_counts(afl_forkserver_t *fsrv) { inline void classify_counts(afl_forkserver_t *fsrv) {
u32 *mem = (u32 *)fsrv->trace_bits; u32 *mem = (u32 *)fsrv->trace_bits;
u32 i = (fsrv->map_size >> 2); u32 i = (fsrv->map_size >> 2);
while (i--) { while (i--) {
@ -64,6 +65,7 @@ inline void classify_counts(afl_forkserver_t *fsrv) {
mem++; mem++;
} }
} }
/* Updates the virgin bits, then reflects whether a new count or a new tuple is /* Updates the virgin bits, then reflects whether a new count or a new tuple is

View File

@ -11,8 +11,8 @@
#include <immintrin.h> #include <immintrin.h>
#endif #endif
u32 skim(const u64 *virgin, const u64 *current, const u64 *current_end); u32 skim(const u64 *virgin, const u64 *current, const u64 *current_end);
u64 classify_word(u64 word); u64 classify_word(u64 word);
inline u64 classify_word(u64 word) { inline u64 classify_word(u64 word) {
@ -62,8 +62,9 @@ void simplify_trace(afl_state_t *afl, u8 *bytes) {
} }
inline void classify_counts(afl_forkserver_t *fsrv) { inline void classify_counts(afl_forkserver_t *fsrv) {
u64 *mem = (u64 *)fsrv->trace_bits; u64 *mem = (u64 *)fsrv->trace_bits;
u32 i = (fsrv->map_size >> 3); u32 i = (fsrv->map_size >> 3);
while (i--) { while (i--) {
@ -74,6 +75,7 @@ inline void classify_counts(afl_forkserver_t *fsrv) {
mem++; mem++;
} }
} }
/* Updates the virgin bits, then reflects whether a new count or a new tuple is /* Updates the virgin bits, then reflects whether a new count or a new tuple is

View File

@ -468,6 +468,7 @@ void write_crash_readme(afl_state_t *afl) {
u8 __attribute__((hot)) save_if_interesting(afl_state_t *afl, void *mem, u8 __attribute__((hot)) save_if_interesting(afl_state_t *afl, void *mem,
u32 len, u8 fault) { u32 len, u8 fault) {
u8 classified = 0; u8 classified = 0;
if (unlikely(len == 0)) { return 0; } if (unlikely(len == 0)) { return 0; }
@ -554,14 +555,17 @@ u8 __attribute__((hot)) save_if_interesting(afl_state_t *afl, void *mem,
if (unlikely(afl->san_binary_length) && if (unlikely(afl->san_binary_length) &&
likely(afl->san_abstraction == UNIQUE_TRACE)) { likely(afl->san_abstraction == UNIQUE_TRACE)) {
// If schedule is not FAST..RARE, we need to classify counts here // If schedule is not FAST..RARE, we need to classify counts here
// Note: SAND was evaluated under FAST schedule but should also work // Note: SAND was evaluated under FAST schedule but should also work
// with other scedules. // with other scedules.
if (!classified) { if (!classified) {
classify_counts(&afl->fsrv); classify_counts(&afl->fsrv);
classified = 1; classified = 1;
} }
cksum_unique = cksum_unique =
hash32(afl->fsrv.trace_bits, afl->fsrv.map_size, HASH_CONST); hash32(afl->fsrv.trace_bits, afl->fsrv.map_size, HASH_CONST);
if (unlikely(!bitmap_read(afl->n_fuzz_dup, cksum) && if (unlikely(!bitmap_read(afl->n_fuzz_dup, cksum) &&
@ -625,11 +629,16 @@ u8 __attribute__((hot)) save_if_interesting(afl_state_t *afl, void *mem,
/* If we are in coverage increasing abstraction and have fed input to /* If we are in coverage increasing abstraction and have fed input to
sanitizers, we are sure it has new bits.*/ sanitizers, we are sure it has new bits.*/
if (classified) { if (classified) {
/* We could have classified the bits in SAND with UNIQUE_TRACE */ /* We could have classified the bits in SAND with UNIQUE_TRACE */
new_bits = has_new_bits(afl, afl->virgin_bits); new_bits = has_new_bits(afl, afl->virgin_bits);
} else { } else {
new_bits = has_new_bits_unclassified(afl, afl->virgin_bits); new_bits = has_new_bits_unclassified(afl, afl->virgin_bits);
} }
} }
if (likely(!new_bits)) { if (likely(!new_bits)) {