mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 18:48:08 +00:00
* Revert "fixed potential double free in custom trim (#881)" This reverts commite9d2f72382
. * Revert "fix custom trim for increasing data" This reverts commit86a8ef168d
. * Fix memory errors when trim causes testcase growth Modify trim_case_custom to avoid writing into in_buf because some custom mutators can cause the testcase to grow rather than shrink. Instead of modifying in_buf directly, we write the update out to the disk when trimming is complete, and then the caller is responsible for refreshing the in-memory buffer from the file. This is still a bit sketchy because it does need to modify q->len in order to notify the upper layers that something changed, and it could end up telling upper layer code that the q->len is *bigger* than the buffer (q->testcase_buf) that contains it, which is asking for trouble down the line somewhere... * Fix an unlikely situation Put back some `unlikely()` calls that were in thee9d2f72382
commit that was reverted.
This commit is contained in:
@ -718,10 +718,7 @@ void sync_fuzzers(afl_state_t *afl) {
|
||||
trimmer uses power-of-two increments somewhere between 1/16 and 1/1024 of
|
||||
file size, to keep the stage short and sweet. */
|
||||
|
||||
u8 trim_case(afl_state_t *afl, struct queue_entry *q, u8 **in_buf_p) {
|
||||
|
||||
// We need to pass pointers around, as growing testcases may need to realloc.
|
||||
u8 *in_buf = *in_buf_p;
|
||||
u8 trim_case(afl_state_t *afl, struct queue_entry *q, u8 *in_buf) {
|
||||
|
||||
u32 orig_len = q->len;
|
||||
|
||||
@ -735,8 +732,7 @@ u8 trim_case(afl_state_t *afl, struct queue_entry *q, u8 **in_buf_p) {
|
||||
|
||||
if (el->afl_custom_trim) {
|
||||
|
||||
trimmed_case = trim_case_custom(afl, q, in_buf_p, el);
|
||||
in_buf = *in_buf_p;
|
||||
trimmed_case = trim_case_custom(afl, q, in_buf, el);
|
||||
custom_trimmed = true;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user