diff --git a/src/include/deepstate/DeepState.h b/src/include/deepstate/DeepState.h index 518411f..1020910 100644 --- a/src/include/deepstate/DeepState.h +++ b/src/include/deepstate/DeepState.h @@ -235,7 +235,11 @@ DEEPSTATE_INLINE static void DeepState_Check(int expr) { DEEPSTATE_INLINE static tname DeepState_ ## Tname ## InRange( \ tname low, tname high) { \ tname x = DeepState_ ## Tname(); \ - (void) DeepState_Assume(low <= x && x <= high); \ + if (!(DeepState_UsingLibFuzzer || HAS_FLAG_input_test_file \ + || HAS_FLAG_input_test_dir || HAS_FLAG_input_test_files_dir)) \ + (void) DeepState_Assume(low <= x && x <= high); \ + else \ + x = low + (x%((high+1)-low)); \ return x; \ } diff --git a/src/lib/DeepState.c b/src/lib/DeepState.c index e6395ed..91bbfc4 100644 --- a/src/lib/DeepState.c +++ b/src/lib/DeepState.c @@ -298,6 +298,9 @@ int32_t DeepState_MaxInt(int32_t v) { void _DeepState_Assume(int expr, const char *expr_str, const char *file, unsigned line) { if (!expr) { + DeepState_LogFormat(DeepState_LogError, + "%s(%u): Assumption %s failed", + file, line, expr_str); DeepState_Abandon("Assumption failed"); } } @@ -598,6 +601,13 @@ extern int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { enum DeepState_TestRunResult result = DeepState_RunTestLLVM(test); + const char* abort_check = getenv("LIBFUZZER_ABORT_ON_FAIL"); + if (abort_check != NULL) { + if ((result == DeepState_TestRunFail) || (result == DeepState_TestRunCrash)) { + abort(); + } + } + DeepState_Teardown(); DeepState_CurrentTestRun = NULL; free(mem);