mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-19 04:58:08 +00:00
cmplog cleanup
This commit is contained in:
@ -590,7 +590,7 @@ typedef struct afl_state {
|
|||||||
|
|
||||||
u32 rand_cnt; /* Random number counter */
|
u32 rand_cnt; /* Random number counter */
|
||||||
|
|
||||||
/* unsigned long rand_seed[3]; would also work */
|
/* unsigned long rand_seed[3]; would also work */
|
||||||
AFL_RAND_RETURN rand_seed[3];
|
AFL_RAND_RETURN rand_seed[3];
|
||||||
s64 init_seed;
|
s64 init_seed;
|
||||||
|
|
||||||
|
@ -99,12 +99,12 @@ static u8 get_exec_checksum(afl_state_t *afl, u8 *buf, u32 len, u64 *cksum) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rand_replace(afl_state_t *afl, u8 *buf, u32 len) {
|
static void xor_replace(u8 *buf, u32 len) {
|
||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i) {
|
||||||
|
|
||||||
buf[i] = rand_below(afl, 256);
|
buf[i] ^= 0xff;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +115,6 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum) {
|
|||||||
struct range *ranges = add_range(NULL, 0, len);
|
struct range *ranges = add_range(NULL, 0, len);
|
||||||
u8 * backup = ck_alloc_nozero(len);
|
u8 * backup = ck_alloc_nozero(len);
|
||||||
|
|
||||||
u8 needs_write = 0;
|
|
||||||
|
|
||||||
u64 orig_hit_cnt, new_hit_cnt;
|
u64 orig_hit_cnt, new_hit_cnt;
|
||||||
orig_hit_cnt = afl->queued_paths + afl->unique_crashes;
|
orig_hit_cnt = afl->queued_paths + afl->unique_crashes;
|
||||||
|
|
||||||
@ -136,7 +134,7 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum) {
|
|||||||
/* Range not empty */
|
/* Range not empty */
|
||||||
|
|
||||||
memcpy(backup, buf + rng->start, s);
|
memcpy(backup, buf + rng->start, s);
|
||||||
rand_replace(afl, buf + rng->start, s);
|
xor_replace(buf + rng->start, s);
|
||||||
|
|
||||||
u64 cksum;
|
u64 cksum;
|
||||||
u64 start_us = get_cur_time_us();
|
u64 start_us = get_cur_time_us();
|
||||||
@ -158,10 +156,6 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum) {
|
|||||||
ranges = add_range(ranges, rng->start + s / 2 + 1, rng->end);
|
ranges = add_range(ranges, rng->start + s / 2 + 1, rng->end);
|
||||||
memcpy(buf + rng->start, backup, s);
|
memcpy(buf + rng->start, backup, s);
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
needs_write = 1;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -191,32 +185,6 @@ static u8 colorization(afl_state_t *afl, u8 *buf, u32 len, u64 exec_cksum) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the input with the high entropy
|
|
||||||
|
|
||||||
if (needs_write) {
|
|
||||||
|
|
||||||
s32 fd;
|
|
||||||
|
|
||||||
if (afl->no_unlink) {
|
|
||||||
|
|
||||||
fd = open(afl->queue_cur->fname, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
unlink(afl->queue_cur->fname); /* ignore errors */
|
|
||||||
fd = open(afl->queue_cur->fname, O_WRONLY | O_CREAT | O_EXCL, 0600);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fd < 0) { PFATAL("Unable to create '%s'", afl->queue_cur->fname); }
|
|
||||||
|
|
||||||
ck_write(fd, buf, len, afl->queue_cur->fname);
|
|
||||||
afl->queue_cur->len = len; // no-op, just to be 100% safe
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
checksum_fail:
|
checksum_fail:
|
||||||
@ -232,8 +200,6 @@ checksum_fail:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: clang notices a _potential_ leak of mem pointed to by rng
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ void free(void *ptr) {
|
|||||||
len = PTR_L(ptr);
|
len = PTR_L(ptr);
|
||||||
|
|
||||||
total_mem -= len;
|
total_mem -= len;
|
||||||
u8 * ptr_ = ptr;
|
u8 *ptr_ = ptr;
|
||||||
|
|
||||||
if (align_allocations && (len & (ALLOC_ALIGN_SIZE - 1))) {
|
if (align_allocations && (len & (ALLOC_ALIGN_SIZE - 1))) {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user