mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-15 19:38:09 +00:00
Remove get_cut_time function from multiple places and refactor code
This commit is contained in:
@ -461,8 +461,9 @@ extern s32 cmplog_child_pid, cmplog_forksrv_pid;
|
|||||||
/* Custom mutators */
|
/* Custom mutators */
|
||||||
|
|
||||||
struct custom_mutator {
|
struct custom_mutator {
|
||||||
|
|
||||||
const char* name;
|
const char* name;
|
||||||
void* dh;
|
void* dh;
|
||||||
|
|
||||||
/* hooks for the custom mutator function */
|
/* hooks for the custom mutator function */
|
||||||
|
|
||||||
@ -485,8 +486,8 @@ struct custom_mutator {
|
|||||||
* @param[in] buf_size Size of the input/output data
|
* @param[in] buf_size Size of the input/output data
|
||||||
* @param[in] add_buf Buffer containing the additional test case
|
* @param[in] add_buf Buffer containing the additional test case
|
||||||
* @param[in] add_buf_size Size of the additional test case
|
* @param[in] add_buf_size Size of the additional test case
|
||||||
* @param[in] max_size Maximum size of the mutated output. The mutation must not
|
* @param[in] max_size Maximum size of the mutated output. The mutation must
|
||||||
* produce data larger than max_size.
|
* not produce data larger than max_size.
|
||||||
* @return Size of the mutated output.
|
* @return Size of the mutated output.
|
||||||
*/
|
*/
|
||||||
size_t (*afl_custom_fuzz)(u8** buf, size_t buf_size, u8* add_buf,
|
size_t (*afl_custom_fuzz)(u8** buf, size_t buf_size, u8* add_buf,
|
||||||
@ -560,7 +561,7 @@ struct custom_mutator {
|
|||||||
* steps returned in init_trim)
|
* steps returned in init_trim)
|
||||||
*/
|
*/
|
||||||
u32 (*afl_custom_post_trim)(u8 success);
|
u32 (*afl_custom_post_trim)(u8 success);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a single custom mutation on a given input.
|
* Perform a single custom mutation on a given input.
|
||||||
* This mutation is stacked with the other muatations in havoc.
|
* This mutation is stacked with the other muatations in havoc.
|
||||||
@ -574,8 +575,9 @@ struct custom_mutator {
|
|||||||
* not produce data larger than max_size.
|
* not produce data larger than max_size.
|
||||||
* @return Size of the mutated output.
|
* @return Size of the mutated output.
|
||||||
*/
|
*/
|
||||||
size_t (*afl_custom_havoc_mutation)(u8** buf, size_t buf_size, size_t max_size);
|
size_t (*afl_custom_havoc_mutation)(u8** buf, size_t buf_size,
|
||||||
|
size_t max_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the probability (in percentage) that afl_custom_havoc_mutation
|
* Return the probability (in percentage) that afl_custom_havoc_mutation
|
||||||
* is called in havoc. By default it is 6 %.
|
* is called in havoc. By default it is 6 %.
|
||||||
@ -598,7 +600,7 @@ struct custom_mutator {
|
|||||||
u8 (*afl_custom_queue_get)(const u8* filename);
|
u8 (*afl_custom_queue_get)(const u8* filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow for additional analysis (e.g. calling a different tool that does a
|
* Allow for additional analysis (e.g. calling a different tool that does a
|
||||||
* different kind of coverage and saves this for the custom mutator).
|
* different kind of coverage and saves this for the custom mutator).
|
||||||
*
|
*
|
||||||
* (Optional)
|
* (Optional)
|
||||||
@ -609,6 +611,7 @@ struct custom_mutator {
|
|||||||
*/
|
*/
|
||||||
void (*afl_custom_queue_new_entry)(const u8* filename_new_queue,
|
void (*afl_custom_queue_new_entry)(const u8* filename_new_queue,
|
||||||
const u8* filename_orig_queue);
|
const u8* filename_orig_queue);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct custom_mutator* mutator;
|
extern struct custom_mutator* mutator;
|
||||||
@ -680,8 +683,8 @@ u8 trim_case_custom(char** argv, struct queue_entry* q, u8* in_buf);
|
|||||||
/* Python */
|
/* Python */
|
||||||
#ifdef USE_PYTHON
|
#ifdef USE_PYTHON
|
||||||
|
|
||||||
int init_py_module(u8*);
|
int init_py_module(u8*);
|
||||||
void finalize_py_module();
|
void finalize_py_module();
|
||||||
|
|
||||||
void init_py(unsigned int);
|
void init_py(unsigned int);
|
||||||
size_t fuzz_py(u8**, size_t, u8*, size_t, size_t);
|
size_t fuzz_py(u8**, size_t, u8*, size_t, size_t);
|
||||||
@ -855,32 +858,6 @@ static u64 next_p2(u64 val) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get unix time in milliseconds */
|
|
||||||
|
|
||||||
static u64 get_cur_time(void) {
|
|
||||||
|
|
||||||
struct timeval tv;
|
|
||||||
struct timezone tz;
|
|
||||||
|
|
||||||
gettimeofday(&tv, &tz);
|
|
||||||
|
|
||||||
return (tv.tv_sec * 1000ULL) + (tv.tv_usec / 1000);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get unix time in microseconds */
|
|
||||||
|
|
||||||
static u64 get_cur_time_us(void) {
|
|
||||||
|
|
||||||
struct timeval tv;
|
|
||||||
struct timezone tz;
|
|
||||||
|
|
||||||
gettimeofday(&tv, &tz);
|
|
||||||
|
|
||||||
return (tv.tv_sec * 1000000ULL) + tv.tv_usec;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _AFL_DOCUMENT_MUTATIONS
|
#ifdef _AFL_DOCUMENT_MUTATIONS
|
||||||
extern u8 do_document;
|
extern u8 do_document;
|
||||||
extern u32 document_counter;
|
extern u32 document_counter;
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#ifndef __AFLCOMMON_H
|
#ifndef __AFLCOMMON_H
|
||||||
#define __AFLCOMMON_H
|
#define __AFLCOMMON_H
|
||||||
|
|
||||||
|
#include <sys/time.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
extern u8* target_path; /* Path to target binary */
|
extern u8* target_path; /* Path to target binary */
|
||||||
@ -37,3 +39,29 @@ char** get_wine_argv(u8* own_loc, char** argv, int argc);
|
|||||||
char* get_afl_env(char* env);
|
char* get_afl_env(char* env);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Get unix time in milliseconds */
|
||||||
|
|
||||||
|
static u64 get_cur_time(void) {
|
||||||
|
|
||||||
|
struct timeval tv;
|
||||||
|
struct timezone tz;
|
||||||
|
|
||||||
|
gettimeofday(&tv, &tz);
|
||||||
|
|
||||||
|
return (tv.tv_sec * 1000ULL) + (tv.tv_usec / 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get unix time in microseconds */
|
||||||
|
|
||||||
|
static u64 get_cur_time_us(void) {
|
||||||
|
|
||||||
|
struct timeval tv;
|
||||||
|
struct timezone tz;
|
||||||
|
|
||||||
|
gettimeofday(&tv, &tz);
|
||||||
|
|
||||||
|
return (tv.tv_sec * 1000000ULL) + tv.tv_usec;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
|
#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
|
||||||
defined(__APPLE__) || defined(__DragonFly__)
|
defined(__APPLE__) || defined(__DragonFly__)
|
||||||
@ -72,19 +73,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif /* __linux__ || __FreeBSD__ || __NetBSD__ || __APPLE__ */
|
#endif /* __linux__ || __FreeBSD__ || __NetBSD__ || __APPLE__ */
|
||||||
|
|
||||||
/* Get unix time in microseconds. */
|
|
||||||
|
|
||||||
static u64 get_cur_time_us(void) {
|
|
||||||
|
|
||||||
struct timeval tv;
|
|
||||||
struct timezone tz;
|
|
||||||
|
|
||||||
gettimeofday(&tv, &tz);
|
|
||||||
|
|
||||||
return (tv.tv_sec * 1000000ULL) + tv.tv_usec;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get CPU usage in microseconds. */
|
/* Get CPU usage in microseconds. */
|
||||||
|
|
||||||
static u64 get_cpu_usage_us(void) {
|
static u64 get_cpu_usage_us(void) {
|
||||||
|
Reference in New Issue
Block a user