mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Place upper bound number on number of array dimensions
This commit is contained in:
parent
3cfeca33c1
commit
12ed08eddb
test/tools/ossfuzz
@ -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() ?
|
||||
|
@ -258,6 +258,7 @@ template <typename T>
|
||||
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<std::string, std::string> visit(BoolType const&) override;
|
||||
std::pair<std::string, std::string> 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<bool>
|
||||
{
|
||||
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<bool>::visit;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user