From 12ed08eddb7610409d5c470a5b4c64598b4a0a36 Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Sun, 6 Oct 2019 09:02:27 +0200 Subject: [PATCH] Place upper bound number on number of array dimensions --- test/tools/ossfuzz/protoToAbiV2.cpp | 1 + test/tools/ossfuzz/protoToAbiV2.h | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/tools/ossfuzz/protoToAbiV2.cpp b/test/tools/ossfuzz/protoToAbiV2.cpp index aa35c80c8..01af91cde 100644 --- a/test/tools/ossfuzz/protoToAbiV2.cpp +++ b/test/tools/ossfuzz/protoToAbiV2.cpp @@ -548,6 +548,7 @@ string TypeVisitor::visit(ArrayType const& _type) { if (!ValidityVisitor().visit(_type)) return ""; + string baseType = visit(_type.t()); solAssert(!baseType.empty(), ""); string arrayBraces = _type.is_static() ? diff --git a/test/tools/ossfuzz/protoToAbiV2.h b/test/tools/ossfuzz/protoToAbiV2.h index a04e36af2..9b6349ea4 100644 --- a/test/tools/ossfuzz/protoToAbiV2.h +++ b/test/tools/ossfuzz/protoToAbiV2.h @@ -258,6 +258,7 @@ template class AbiV2ProtoVisitor { public: + static unsigned constexpr s_maxArrayDimensions = 3; virtual ~AbiV2ProtoVisitor() = default; virtual T visit(BoolType const& _node) = 0; @@ -533,7 +534,6 @@ public: m_indentation = 2; m_stateVar = _stateVar; m_structCounter = m_structStart = _structCounter; - m_arrayOfStruct = false; } std::pair visit(BoolType const&) override; std::pair visit(IntegerType const&) override; @@ -587,7 +587,6 @@ private: bool m_stateVar; unsigned m_structCounter; unsigned m_structStart; - bool m_arrayOfStruct; }; /// Returns a valid value (as a string) for a given type. @@ -671,7 +670,7 @@ private: class ValidityVisitor: AbiV2ProtoVisitor { public: - ValidityVisitor() = default; + ValidityVisitor(): m_arrayDimensions(0) {} bool visit(BoolType const&) override { @@ -700,6 +699,9 @@ public: bool visit(ArrayType const& _type) override { + m_arrayDimensions++; + if (m_arrayDimensions > s_maxArrayDimensions) + return false; return visit(_type.t()); } @@ -711,6 +713,7 @@ public: return false; } + unsigned m_arrayDimensions; using AbiV2ProtoVisitor::visit; };