diff options
author | vanhauser-thc <vh@thc.org> | 2023-02-16 07:47:36 +0100 |
---|---|---|
committer | vanhauser-thc <vh@thc.org> | 2023-02-16 07:47:36 +0100 |
commit | 1faf6f67313e726c645ac3b9ecd2d8b5e65f605a (patch) | |
tree | bba53945857af75b1d43d31e9ee14ee0db8ef4ea /custom_mutators | |
parent | 7f2bafbb8b709720cd3703789071c08064e518bd (diff) | |
download | afl++-1faf6f67313e726c645ac3b9ecd2d8b5e65f605a.tar.gz |
fix
Diffstat (limited to 'custom_mutators')
-rw-r--r-- | custom_mutators/autotokens/autotokens.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/custom_mutators/autotokens/autotokens.cpp b/custom_mutators/autotokens/autotokens.cpp index 22c78a60..8135aba1 100644 --- a/custom_mutators/autotokens/autotokens.cpp +++ b/custom_mutators/autotokens/autotokens.cpp @@ -401,25 +401,28 @@ extern "C" size_t afl_custom_fuzz(my_mutator_t *data, u8 *buf, size_t buf_size, /* Now we create the output */ output = ""; - u32 prev_size = 0; + u32 prev_size = 1, was_whitespace = 1; for (i = 0; i < m_size; ++i) { if (likely(i + 1 < m_size)) { u32 this_size = id_to_token[m[i]].size(); + u32 is_whitespace = m[i] < whitespace_ids; /* The output we are generating might need repairing. General rule: two items that have a size larger than 2 are strings or identifizers and need a whitespace or an item of length 1 in between. */ - if (unlikely(prev_size > 1 && this_size > 1)) { + if (unlikely(!(prev_size == 1 || was_whitespace || this_size == 1 || + is_whitespace))) { output += id_to_token[good_whitespace_or_singleval()]; } prev_size = this_size; + was_whitespace = is_whitespace; } |