Merge pull request #4825 from ethereum/expressionCompBareCall

More safeguards for (library) function types.
This commit is contained in:
chriseth 2018-08-16 14:38:44 +02:00 committed by GitHub
commit c274af0770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 5 deletions

View File

@ -2929,6 +2929,17 @@ string FunctionType::externalSignature() const
{ {
solAssert(m_declaration != nullptr, "External signature of function needs declaration"); solAssert(m_declaration != nullptr, "External signature of function needs declaration");
solAssert(!m_declaration->name().empty(), "Fallback function has no signature."); solAssert(!m_declaration->name().empty(), "Fallback function has no signature.");
switch (kind())
{
case Kind::Internal:
case Kind::External:
case Kind::CallCode:
case Kind::DelegateCall:
case Kind::Event:
break;
default:
solAssert(false, "Invalid function type for requesting external signature.");
}
bool const inLibrary = dynamic_cast<ContractDefinition const&>(*m_declaration->scope()).isLibrary(); bool const inLibrary = dynamic_cast<ContractDefinition const&>(*m_declaration->scope()).isLibrary();
FunctionTypePointer external = interfaceFunctionType(); FunctionTypePointer external = interfaceFunctionType();

View File

@ -1165,19 +1165,19 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
solAssert(false, "event not found"); solAssert(false, "event not found");
// no-op, because the parent node will do the job // no-op, because the parent node will do the job
break; break;
case FunctionType::Kind::DelegateCall:
_memberAccess.expression().accept(*this);
m_context << funType->externalIdentifier();
break;
case FunctionType::Kind::CallCode:
case FunctionType::Kind::External: case FunctionType::Kind::External:
case FunctionType::Kind::Creation: case FunctionType::Kind::Creation:
case FunctionType::Kind::DelegateCall:
case FunctionType::Kind::CallCode:
case FunctionType::Kind::Send: case FunctionType::Kind::Send:
case FunctionType::Kind::BareCall: case FunctionType::Kind::BareCall:
case FunctionType::Kind::BareCallCode: case FunctionType::Kind::BareCallCode:
case FunctionType::Kind::BareDelegateCall: case FunctionType::Kind::BareDelegateCall:
case FunctionType::Kind::BareStaticCall: case FunctionType::Kind::BareStaticCall:
case FunctionType::Kind::Transfer: case FunctionType::Kind::Transfer:
_memberAccess.expression().accept(*this);
m_context << funType->externalIdentifier();
break;
case FunctionType::Kind::Log0: case FunctionType::Kind::Log0:
case FunctionType::Kind::Log1: case FunctionType::Kind::Log1:
case FunctionType::Kind::Log2: case FunctionType::Kind::Log2: