| 47 | extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size); |
| 48 | |
| 49 | extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size) |
| 50 | { |
| 51 | if (_size > 600) |
| 52 | return 0; |
| 53 | |
| 54 | std::string input(reinterpret_cast<char const*>(_data), _size); |
| 55 | |
| 56 | if (std::any_of(input.begin(), input.end(), [](char c) { |
| 57 | return ((static_cast<unsigned char>(c) > 127) || !(isPrint(c) || (c == '\n') || (c == '\t'))); |
| 58 | })) |
| 59 | return 0; |
| 60 | |
| 61 | YulStringRepository::reset(); |
| 62 | |
| 63 | YulStack stack( |
| 64 | langutil::EVMVersion(), |
| 65 | std::nullopt, |
| 66 | solidity::frontend::OptimiserSettings::full(), |
| 67 | DebugInfoSelection::AllExceptExperimental() |
| 68 | ); |
| 69 | try |
| 70 | { |
| 71 | if ( |
| 72 | !stack.parseAndAnalyze("source", input) || |
| 73 | !stack.parserResult()->hasCode() || |
| 74 | !stack.parserResult()->analysisInfo |
| 75 | ) |
| 76 | return 0; |
| 77 | } |
| 78 | catch (Exception const&) |
| 79 | { |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | std::ostringstream os1; |
| 84 | std::ostringstream os2; |
| 85 | // Disable memory tracing to avoid false positive reports |
| 86 | // such as unused write to memory e.g., |
| 87 | // { mstore(0, 1) } |
| 88 | // that would be removed by the redundant store eliminator. |
| 89 | // TODO: Add EOF support |
| 90 | yulFuzzerUtil::TerminationReason termReason = yulFuzzerUtil::interpret( |
| 91 | os1, |
| 92 | *stack.parserResult()->code(), |
| 93 | /*disableMemoryTracing=*/true |
| 94 | ); |
| 95 | if (yulFuzzerUtil::resourceLimitsExceeded(termReason)) |
| 96 | return 0; |
| 97 | |
| 98 | stack.optimize(); |
| 99 | termReason = yulFuzzerUtil::interpret( |
| 100 | os2, |
| 101 | *stack.parserResult()->code(), |
| 102 | /*disableMemoryTracing=*/true |
| 103 | ); |
| 104 | |
| 105 | if (yulFuzzerUtil::resourceLimitsExceeded(termReason)) |
| 106 | return 0; |
nothing calls this directly
no test coverage detected