mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3570 from ethereum/assembly-oversized-literals
Raise error on oversized number literals in assembly
This commit is contained in:
commit
ca35963f84
@ -6,6 +6,7 @@ Features:
|
||||
* Type Checker: Disallow uninitialized storage pointers as experimental 0.5.0 feature.
|
||||
|
||||
Bugfixes:
|
||||
* Assembly: Raise error on oversized number literals in assembly.
|
||||
* JSON-AST: Add "documentation" property to function, event and modifier definition.
|
||||
* Resolver: Properly determine shadowing for imports with aliases.
|
||||
* Standalone Assembly: Do not ignore input after closing brace of top level block.
|
||||
|
@ -82,6 +82,19 @@ bool AsmAnalyzer::operator()(assembly::Literal const& _literal)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
else if (_literal.kind == assembly::LiteralKind::Number && bigint(_literal.value) > u256(-1))
|
||||
{
|
||||
m_errorReporter.typeError(
|
||||
_literal.location,
|
||||
"Number literal too large (> 256 bits)"
|
||||
);
|
||||
return false;
|
||||
}
|
||||
else if (_literal.kind == assembly::LiteralKind::Boolean)
|
||||
{
|
||||
solAssert(m_flavour == AsmFlavour::IULIA, "");
|
||||
solAssert(_literal.value == "true" || _literal.value == "false", "");
|
||||
}
|
||||
m_info.stackHeightInfo[&_literal] = m_stackHeight;
|
||||
return true;
|
||||
}
|
||||
|
@ -228,6 +228,7 @@ BOOST_AUTO_TEST_CASE(number_literals)
|
||||
CHECK_ERROR("{ let x:u256 := .1:u256 }", ParserError, "Invalid number literal.");
|
||||
CHECK_ERROR("{ let x:u256 := 1e5:u256 }", ParserError, "Invalid number literal.");
|
||||
CHECK_ERROR("{ let x:u256 := 67.235:u256 }", ParserError, "Invalid number literal.");
|
||||
CHECK_ERROR("{ let x:u256 := 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff:u256 }", TypeError, "Number literal too large (> 256 bits)");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(builtin_types)
|
||||
|
@ -390,6 +390,7 @@ BOOST_AUTO_TEST_CASE(number_literals)
|
||||
CHECK_PARSE_ERROR("{ let x := .1 }", ParserError, "Invalid number literal.");
|
||||
CHECK_PARSE_ERROR("{ let x := 1e5 }", ParserError, "Invalid number literal.");
|
||||
CHECK_PARSE_ERROR("{ let x := 67.235 }", ParserError, "Invalid number literal.");
|
||||
CHECK_STRICT_ERROR("{ let x := 0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff }", TypeError, "Number literal too large (> 256 bits)");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(function_definitions)
|
||||
|
Loading…
Reference in New Issue
Block a user