mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Abiv2 proto fuzzer: Crop at least 32 bytes if last dynamically encoded parameter is right padded
This commit is contained in:
parent
7e80fcebc1
commit
e349fb1ce1
@ -63,8 +63,6 @@ void ProtoConverter::visitType(
|
|||||||
std::string varName, paramName;
|
std::string varName, paramName;
|
||||||
createDeclAndParamList(_type, _dataType, varName, paramName);
|
createDeclAndParamList(_type, _dataType, varName, paramName);
|
||||||
addCheckedVarDef(_dataType, varName, paramName, _value);
|
addCheckedVarDef(_dataType, varName, paramName, _value);
|
||||||
// Update right padding of type
|
|
||||||
m_isLastParamRightPadded = isDataTypeBytesOrString(_dataType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProtoConverter::appendVarDeclToOutput(
|
void ProtoConverter::appendVarDeclToOutput(
|
||||||
@ -451,6 +449,8 @@ void ProtoConverter::visit(DynamicByteArrayType const& _x)
|
|||||||
isBytes
|
isBytes
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
// Update right padding of type
|
||||||
|
m_isLastDynParamRightPadded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement struct visitor
|
// TODO: Implement struct visitor
|
||||||
@ -658,23 +658,23 @@ void ProtoConverter::visit(ArrayType const& _x)
|
|||||||
{
|
{
|
||||||
case ArrayType::kInty:
|
case ArrayType::kInty:
|
||||||
baseType = getIntTypeAsString(_x.inty());
|
baseType = getIntTypeAsString(_x.inty());
|
||||||
m_isLastParamRightPadded = false;
|
m_isLastDynParamRightPadded = false;
|
||||||
break;
|
break;
|
||||||
case ArrayType::kByty:
|
case ArrayType::kByty:
|
||||||
baseType = getFixedByteTypeAsString(_x.byty());
|
baseType = getFixedByteTypeAsString(_x.byty());
|
||||||
m_isLastParamRightPadded = false;
|
m_isLastDynParamRightPadded = false;
|
||||||
break;
|
break;
|
||||||
case ArrayType::kAdty:
|
case ArrayType::kAdty:
|
||||||
baseType = getAddressTypeAsString(_x.adty());
|
baseType = getAddressTypeAsString(_x.adty());
|
||||||
m_isLastParamRightPadded = false;
|
m_isLastDynParamRightPadded = false;
|
||||||
break;
|
break;
|
||||||
case ArrayType::kBoolty:
|
case ArrayType::kBoolty:
|
||||||
baseType = getBoolTypeAsString();
|
baseType = getBoolTypeAsString();
|
||||||
m_isLastParamRightPadded = false;
|
m_isLastDynParamRightPadded = false;
|
||||||
break;
|
break;
|
||||||
case ArrayType::kDynbytesty:
|
case ArrayType::kDynbytesty:
|
||||||
baseType = bytesArrayTypeAsString(_x.dynbytesty());
|
baseType = bytesArrayTypeAsString(_x.dynbytesty());
|
||||||
m_isLastParamRightPadded = true;
|
m_isLastDynParamRightPadded = true;
|
||||||
break;
|
break;
|
||||||
case ArrayType::kStty:
|
case ArrayType::kStty:
|
||||||
case ArrayType::BASE_TYPE_ONEOF_NOT_SET:
|
case ArrayType::BASE_TYPE_ONEOF_NOT_SET:
|
||||||
@ -861,7 +861,7 @@ void ProtoConverter::visit(TestFunction const& _x)
|
|||||||
)")
|
)")
|
||||||
("parameterNames", dev::suffixedVariableNameList(s_varNamePrefix, 0, m_varCounter))
|
("parameterNames", dev::suffixedVariableNameList(s_varNamePrefix, 0, m_varCounter))
|
||||||
("invalidLengthFuzz", std::to_string(_x.invalid_encoding_length()))
|
("invalidLengthFuzz", std::to_string(_x.invalid_encoding_length()))
|
||||||
("isRightPadded", isLastParamRightPadded() ? "true" : "false")
|
("isRightPadded", isLastDynParamRightPadded() ? "true" : "false")
|
||||||
("atLeastOneVar", m_varCounter > 0)
|
("atLeastOneVar", m_varCounter > 0)
|
||||||
.render();
|
.render();
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ public:
|
|||||||
m_counter(0),
|
m_counter(0),
|
||||||
m_varCounter(0),
|
m_varCounter(0),
|
||||||
m_returnValue(1),
|
m_returnValue(1),
|
||||||
m_isLastParamRightPadded(false)
|
m_isLastDynParamRightPadded(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ProtoConverter(ProtoConverter const&) = delete;
|
ProtoConverter(ProtoConverter const&) = delete;
|
||||||
@ -274,9 +274,9 @@ private:
|
|||||||
return ((isValueType(_dataType) || m_isStateVar) ? "" : "memory");
|
return ((isValueType(_dataType) || m_isStateVar) ? "" : "memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isLastParamRightPadded()
|
bool isLastDynParamRightPadded()
|
||||||
{
|
{
|
||||||
return m_isLastParamRightPadded;
|
return m_isLastDynParamRightPadded;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static declarations
|
// Static declarations
|
||||||
@ -466,10 +466,10 @@ private:
|
|||||||
unsigned m_varCounter;
|
unsigned m_varCounter;
|
||||||
/// Monotonically increasing return value for error reporting
|
/// Monotonically increasing return value for error reporting
|
||||||
unsigned m_returnValue;
|
unsigned m_returnValue;
|
||||||
/// Flag that indicates if last parameter passed to a function call
|
/// Flag that indicates if last dynamically encoded parameter
|
||||||
/// is of a type that is going to be right padded by the ABI
|
/// passed to a function call is of a type that is going to be
|
||||||
/// encoder.
|
/// right padded by the ABI encoder.
|
||||||
bool m_isLastParamRightPadded;
|
bool m_isLastDynParamRightPadded;
|
||||||
static unsigned constexpr s_maxArrayLength = 4;
|
static unsigned constexpr s_maxArrayLength = 4;
|
||||||
static unsigned constexpr s_maxArrayDimensions = 4;
|
static unsigned constexpr s_maxArrayDimensions = 4;
|
||||||
static unsigned constexpr s_maxDynArrayLength = 256;
|
static unsigned constexpr s_maxDynArrayLength = 256;
|
||||||
|
Loading…
Reference in New Issue
Block a user