mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 02:28:09 +00:00
Merge pull request #544 from ThomasTNO/export_env_vars
Export set afl_environment_variables to stats
This commit is contained in:
@ -1035,6 +1035,7 @@ without feedback, bug reports, or patches from:
|
|||||||
Andrea Biondo Vincent Le Garrec
|
Andrea Biondo Vincent Le Garrec
|
||||||
Khaled Yakdan Kuang-che Wu
|
Khaled Yakdan Kuang-che Wu
|
||||||
Josephine Calliotte Konrad Welc
|
Josephine Calliotte Konrad Welc
|
||||||
|
Thomas Rooijakkers
|
||||||
```
|
```
|
||||||
|
|
||||||
Thank you!
|
Thank you!
|
||||||
|
@ -945,6 +945,7 @@ void destroy_extras(afl_state_t *);
|
|||||||
|
|
||||||
/* Stats */
|
/* Stats */
|
||||||
|
|
||||||
|
void write_fuzzer_config_file(afl_state_t *);
|
||||||
void write_stats_file(afl_state_t *, double, double, double);
|
void write_stats_file(afl_state_t *, double, double, double);
|
||||||
void maybe_update_plot_file(afl_state_t *, double, double);
|
void maybe_update_plot_file(afl_state_t *, double, double);
|
||||||
void show_stats(afl_state_t *);
|
void show_stats(afl_state_t *);
|
||||||
|
@ -24,8 +24,57 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "afl-fuzz.h"
|
#include "afl-fuzz.h"
|
||||||
|
#include "envs.h"
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
|
/* Open file for writing */
|
||||||
|
|
||||||
|
inline FILE *open_file(const char *fn) {
|
||||||
|
|
||||||
|
s32 fd;
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
||||||
|
|
||||||
|
if (fd < 0) { PFATAL("Unable to create '%s'", fn); }
|
||||||
|
|
||||||
|
f = fdopen(fd, "w");
|
||||||
|
|
||||||
|
if (!f) { PFATAL("fdopen() failed"); }
|
||||||
|
|
||||||
|
return f;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write fuzzer setup file */
|
||||||
|
|
||||||
|
void write_fuzzer_config_file(afl_state_t *afl) {
|
||||||
|
|
||||||
|
u8 fn[PATH_MAX];
|
||||||
|
FILE *f;
|
||||||
|
|
||||||
|
snprintf(fn, PATH_MAX, "%s/fuzzer_config", afl->out_dir);
|
||||||
|
f = open_file(fn);
|
||||||
|
|
||||||
|
char *val;
|
||||||
|
|
||||||
|
uint32_t s_afl_env =
|
||||||
|
sizeof(afl_environment_variables) / sizeof(afl_environment_variables[0]) -
|
||||||
|
1;
|
||||||
|
for (uint32_t i = 0; i < s_afl_env; i++) {
|
||||||
|
|
||||||
|
if ((val = getenv(afl_environment_variables[i])) != NULL) {
|
||||||
|
|
||||||
|
fprintf(f, "%s=%s\n", afl_environment_variables[i], val);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Update stats file for unattended monitoring. */
|
/* Update stats file for unattended monitoring. */
|
||||||
|
|
||||||
void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability,
|
void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability,
|
||||||
@ -36,20 +85,12 @@ void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned long long int cur_time = get_cur_time();
|
unsigned long long int cur_time = get_cur_time();
|
||||||
u8 fn[PATH_MAX];
|
|
||||||
s32 fd;
|
|
||||||
FILE * f;
|
|
||||||
u32 t_bytes = count_non_255_bytes(afl, afl->virgin_bits);
|
u32 t_bytes = count_non_255_bytes(afl, afl->virgin_bits);
|
||||||
|
u8 fn[PATH_MAX];
|
||||||
|
FILE * f;
|
||||||
|
|
||||||
snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir);
|
snprintf(fn, PATH_MAX, "%s/fuzzer_stats", afl->out_dir);
|
||||||
|
f = open_file(fn);
|
||||||
fd = open(fn, O_WRONLY | O_CREAT | O_TRUNC, 0600);
|
|
||||||
|
|
||||||
if (fd < 0) { PFATAL("Unable to create '%s'", fn); }
|
|
||||||
|
|
||||||
f = fdopen(fd, "w");
|
|
||||||
|
|
||||||
if (!f) { PFATAL("fdopen() failed"); }
|
|
||||||
|
|
||||||
/* Keep last values in case we're called from another context
|
/* Keep last values in case we're called from another context
|
||||||
where exec/sec stats and such are not readily available. */
|
where exec/sec stats and such are not readily available. */
|
||||||
@ -163,6 +204,7 @@ void write_stats_file(afl_state_t *afl, double bitmap_cvg, double stability,
|
|||||||
? ""
|
? ""
|
||||||
: "default",
|
: "default",
|
||||||
afl->orig_cmdline);
|
afl->orig_cmdline);
|
||||||
|
|
||||||
/* ignore errors */
|
/* ignore errors */
|
||||||
|
|
||||||
if (afl->debug) {
|
if (afl->debug) {
|
||||||
|
@ -1274,6 +1274,7 @@ int main(int argc, char **argv_orig, char **envp) {
|
|||||||
|
|
||||||
seek_to = find_start_position(afl);
|
seek_to = find_start_position(afl);
|
||||||
|
|
||||||
|
write_fuzzer_config_file(afl);
|
||||||
write_stats_file(afl, 0, 0, 0);
|
write_stats_file(afl, 0, 0, 0);
|
||||||
maybe_update_plot_file(afl, 0, 0);
|
maybe_update_plot_file(afl, 0, 0);
|
||||||
save_auto(afl);
|
save_auto(afl);
|
||||||
|
Reference in New Issue
Block a user