Skip to content

Commit

Permalink
Mutator: fix mutator crash due to output truncated by harness
Browse files Browse the repository at this point in the history
  • Loading branch information
atrosinenko committed Jan 6, 2024
1 parent 1a62750 commit 58ab681
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions runtime/common/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ void res_load_whole_stdin(struct fuzzer_state *state) {
perror("Cannot read input from stdin");
abort();
}

assert(MAX_INPUT_LEN == MUTATOR_MAX_TEST_CASE_LENGTH); // statically known
TRACE(state, "Read %zu bytes of input (max %u).", state->constant_state.length, MAX_INPUT_LEN);
mutator_init_input(state);
for (int id = 0; id < state->current_state.file_name_count; ++id)
Expand Down
3 changes: 2 additions & 1 deletion runtime/include/kbdysch/mutator-defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ struct mutator_log_propose_change {
};
#pragma pack(pop)

#define MUTATOR_MAX_TEST_CASE_LENGTH (1 << 20)
// Should be equal to MAX_INPUT_LEN
#define MUTATOR_MAX_TEST_CASE_LENGTH (1 << 16)

#define MUTATOR_MAX_VARIABLES 100
#define MUTATOR_SHM_VARS_BYTES 65536
Expand Down
3 changes: 2 additions & 1 deletion runtime/mutators/afl-generic-mutator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ uint8_t afl_custom_queue_new_entry(void *data, const char *filename_new_queue,

bool log_saved = save_log_from_shm(state, test_case.as_data(), filename_new_queue);
if (!log_saved && !strstr(filename_new_queue, ",orig:"))
FATAL("Unexpected hash: %s\n", filename_new_queue);
FATAL("Unexpected hash: length=%zu, filename=%s\n",
test_case.size(), filename_new_queue);
// Do not initialize too early
if (log_saved)
accumulate_important_data(state);
Expand Down

0 comments on commit 58ab681

Please sign in to comment.