diff options
author | Arash Partow <ArashPartow@users.noreply.github.com> | 2020-12-07 06:52:24 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-06 11:52:24 -0800 |
commit | f14497dba0b32ff8a7f0514ec6dae961458f9aa5 (patch) | |
tree | 43687780abd31df7b3ce928a48e67fcfe7a38020 /projects/exprtk | |
parent | b9e6a5fc74ae67ec157d66901ad63ae77cd3d431 (diff) | |
download | oss-fuzz-f14497dba0b32ff8a7f0514ec6dae961458f9aa5.tar.gz |
[exprtk] Enable loop upper-bound runtime checks in the fuzzer (#4789)
Diffstat (limited to 'projects/exprtk')
-rw-r--r-- | projects/exprtk/exprtk_fuzzer.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/projects/exprtk/exprtk_fuzzer.cpp b/projects/exprtk/exprtk_fuzzer.cpp index 6612fa1b7..4adfe1d5a 100644 --- a/projects/exprtk/exprtk_fuzzer.cpp +++ b/projects/exprtk/exprtk_fuzzer.cpp @@ -15,15 +15,17 @@ #include <cstdint> #include <string> +#define exprtk_enable_runtime_checks #include "exprtk.hpp" template <typename T> void run(const std::string& expression_string) { - typedef exprtk::symbol_table<T> symbol_table_t; - typedef exprtk::expression<T> expression_t; - typedef exprtk::parser<T> parser_t; + typedef exprtk::symbol_table<T> symbol_table_t; + typedef exprtk::expression<T> expression_t; + typedef exprtk::parser<T> parser_t; + typedef exprtk::loop_runtime_check loop_runtime_check_t; T x = T(1.2345); T y = T(2.2345); @@ -40,10 +42,24 @@ void run(const std::string& expression_string) expression_t expression; expression.register_symbol_table(symbol_table); + loop_runtime_check_t loop_runtime_check; + loop_runtime_check.loop_set = loop_runtime_check_t::e_all_loops; + loop_runtime_check.max_loop_iterations = 100000000; + parser_t parser; + + parser.register_loop_runtime_check(loop_runtime_check); + if (parser.compile(expression_string, expression)) { - expression.value(); + try + { + expression.value(); + } + catch (std::runtime_error& rte) + {} + + parser.clear_loop_runtime_check(); } } |