mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-11 17:51:32 +00:00
Fix formatting
This commit is contained in:
@ -31,7 +31,7 @@ __attribute__((visibility("default"))) void afl_persistent_hook(
|
||||
// do a length check matching the target!
|
||||
|
||||
void **esp = (void **)regs->esp;
|
||||
void * arg1 = esp[0];
|
||||
void *arg1 = esp[0];
|
||||
void **arg2 = &esp[1];
|
||||
memcpy(arg1, input_buf, input_buf_len);
|
||||
*arg2 = (void *)input_buf_len;
|
||||
|
@ -13,7 +13,7 @@ extern gboolean instrument_unique;
|
||||
extern guint64 instrument_hash_zero;
|
||||
extern char *instrument_coverage_unstable_filename;
|
||||
extern gboolean instrument_coverage_insn;
|
||||
extern char * instrument_regs_filename;
|
||||
extern char *instrument_regs_filename;
|
||||
|
||||
extern gboolean instrument_use_fixed_seed;
|
||||
extern guint64 instrument_fixed_seed;
|
||||
|
@ -33,7 +33,7 @@ gboolean instrument_use_fixed_seed = FALSE;
|
||||
guint64 instrument_fixed_seed = 0;
|
||||
char *instrument_coverage_unstable_filename = NULL;
|
||||
gboolean instrument_coverage_insn = FALSE;
|
||||
char * instrument_regs_filename = NULL;
|
||||
char *instrument_regs_filename = NULL;
|
||||
|
||||
static GumStalkerTransformer *transformer = NULL;
|
||||
|
||||
@ -237,9 +237,12 @@ static void instrument_basic_block(GumStalkerIterator *iterator,
|
||||
}
|
||||
|
||||
if (unlikely(instrument_regs_filename != NULL)) {
|
||||
|
||||
gum_stalker_iterator_put_callout(iterator, instrument_write_regs,
|
||||
(void *)(size_t)regs_fd, NULL);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -274,6 +277,7 @@ static void instrument_basic_block(GumStalkerIterator *iterator,
|
||||
instrument_flush(output);
|
||||
instrument_debug_end(output);
|
||||
instrument_coverage_end(instr->address + instr->size);
|
||||
|
||||
}
|
||||
|
||||
void instrument_config(void) {
|
||||
@ -404,6 +408,7 @@ void instrument_init(void) {
|
||||
instrument_regs_filename == NULL ? " " : instrument_regs_filename);
|
||||
|
||||
if (instrument_regs_filename != NULL) {
|
||||
|
||||
char *path =
|
||||
g_canonicalize_filename(instrument_regs_filename, g_get_current_dir());
|
||||
|
||||
@ -415,6 +420,7 @@ void instrument_init(void) {
|
||||
if (regs_fd < 0) { FFATAL("Failed to open regs file '%s'", path); }
|
||||
|
||||
g_free(path);
|
||||
|
||||
}
|
||||
|
||||
asan_init();
|
||||
@ -444,6 +450,7 @@ void instrument_on_fork() {
|
||||
}
|
||||
|
||||
void instrument_regs_format(int fd, char *format, ...) {
|
||||
|
||||
va_list ap;
|
||||
char buffer[4096] = {0};
|
||||
int ret;
|
||||
@ -458,4 +465,6 @@ void instrument_regs_format(int fd, char *format, ...) {
|
||||
len = strnlen(buffer, sizeof(buffer));
|
||||
|
||||
IGNORED_RETURN(write(fd, buffer, len));
|
||||
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,7 @@ void instrument_cache(const cs_insn *instr, GumStalkerOutput *output) {
|
||||
}
|
||||
|
||||
void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {
|
||||
|
||||
int fd = (int)user_data;
|
||||
instrument_regs_format(fd,
|
||||
"r0 : 0x%08x, r1 : 0x%08x, r2 : 0x%08x, r3 : 0x%08x\n",
|
||||
@ -97,6 +98,7 @@ void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {
|
||||
fd, "r12: 0x%08x, sp : 0x%08x, lr : 0x%08x, pc : 0x%08x\n",
|
||||
cpu_context->r12, cpu_context->sp, cpu_context->lr, cpu_context->pc);
|
||||
instrument_regs_format(fd, "cpsr: 0x%08x\n\n", cpu_context->cpsr);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -407,6 +407,7 @@ void instrument_cache(const cs_insn *instr, GumStalkerOutput *output) {
|
||||
}
|
||||
|
||||
void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {
|
||||
|
||||
int fd = (int)(size_t)user_data;
|
||||
instrument_regs_format(
|
||||
fd, "x0 : 0x%016x, x1 : 0x%016x, x2 : 0x%016x, x3 : 0x%016x\n",
|
||||
@ -440,6 +441,7 @@ void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {
|
||||
fd, "x28: 0x%016x, fp : 0x%016x, lr : 0x%016x, sp : 0x%016x\n",
|
||||
cpu_context->x[28], cpu_context->fp, cpu_context->lr, cpu_context->sp);
|
||||
instrument_regs_format(fd, "pc : 0x%016x\n\n", cpu_context->pc);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -63,12 +63,14 @@ static void instrument_disasm(guint8 *start, guint8 *end,
|
||||
|
||||
count = cs_disasm(capstone, curr, size, GPOINTER_TO_SIZE(curr), 0, &insn);
|
||||
if (insn == NULL) {
|
||||
|
||||
instrument_debug("\t0x%" G_GINT64_MODIFIER "x\t* 0x%016" G_GSIZE_MODIFIER
|
||||
"x\n",
|
||||
(uint64_t)(size_t)curr, *(size_t *)curr);
|
||||
|
||||
len += sizeof(size_t);
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i != count; i++) {
|
||||
|
@ -469,6 +469,7 @@ gpointer instrument_cur(GumStalkerOutput *output) {
|
||||
}
|
||||
|
||||
void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {
|
||||
|
||||
int fd = (int)(size_t)user_data;
|
||||
instrument_regs_format(
|
||||
fd, "rax: 0x%016x, rbx: 0x%016x, rcx: 0x%016x, rdx: 0x%016x\n",
|
||||
@ -483,6 +484,7 @@ void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {
|
||||
fd, "r12: 0x%016x, r13: 0x%016x, r14: 0x%016x, r15: 0x%016x\n",
|
||||
cpu_context->r12, cpu_context->r13, cpu_context->r14, cpu_context->r15);
|
||||
instrument_regs_format(fd, "rip: 0x%016x\n\n", cpu_context->rip);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -271,6 +271,7 @@ void instrument_cache(const cs_insn *instr, GumStalkerOutput *output) {
|
||||
}
|
||||
|
||||
void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {
|
||||
|
||||
int fd = (int)(size_t)user_data;
|
||||
instrument_regs_format(
|
||||
fd, "eax: 0x%08x, ebx: 0x%08x, ecx: 0x%08x, edx: 0x%08x\n",
|
||||
@ -279,6 +280,7 @@ void instrument_write_regs(GumCpuContext *cpu_context, gpointer user_data) {
|
||||
fd, "esi: 0x%08x, edi: 0x%08x, ebp: 0x%08x, esp: 0x%08x\n",
|
||||
cpu_context->esi, cpu_context->edi, cpu_context->ebp, cpu_context->esp);
|
||||
instrument_regs_format(fd, "eip: 0x%08x\n\n", cpu_context->eip);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -158,7 +158,9 @@ __attribute__((visibility("default"))) void js_api_set_instrument_no_optimize(
|
||||
|
||||
__attribute__((visibility("default"))) void js_api_set_instrument_regs_file(
|
||||
char *path) {
|
||||
|
||||
instrument_regs_filename = g_strdup(path);
|
||||
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) void js_api_set_instrument_seed(
|
||||
|
Reference in New Issue
Block a user