Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing DOS large exponent in scientific notation constants. #608

Merged
merged 5 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ See the [Printer documentation](https://github.com/crytic/slither/wiki/Printer-d
- `slither-check-upgradeability`: [Review `delegatecall`-based upgradeability](https://github.com/crytic/slither/wiki/Upgradeability-Checks)
- `slither-prop`: [Automatic unit tests and properties generation](https://github.com/crytic/slither/wiki/Properties-generation)
- `slither-flat`: [Flatten a codebase](https://github.com/crytic/slither/wiki/Contract-Flattening)
- `slither-erc`: [Check the ERC's conformance](https://github.com/crytic/slither/wiki/ERC-Conformance)
- `slither-check-erc`: [Check the ERC's conformance](https://github.com/crytic/slither/wiki/ERC-Conformance)
- `slither-format`: [Automatic patches generation](https://github.com/crytic/slither/wiki/Slither-format)

See the [Tool documentation](https://github.com/crytic/slither/wiki/Tool-Documentation) for additional tools.
Expand Down
16 changes: 10 additions & 6 deletions slither/slithir/variables/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ def __init__(self, val, type=None, subdenomination=None):
if val.startswith('0x') or val.startswith('0X'):
self._val = int(val, 16)
else:
if 'e' in val:
base, expo = val.split('e')
self._val = int(Decimal(base) * (10 ** int(expo)))
elif 'E' in val:
base, expo = val.split('E')
self._val = int(Decimal(base) * (10 ** int(expo)))
if 'e' in val or 'E' in val:
base, expo = val.split('e') if 'e' in val else val.split('E')
base, expo = Decimal(base), int(expo)
if expo > 80:
if base != Decimal(0):
raise ValueError("exponent is too large to fit in any Solidity integer size")
else:
self._val = 0
else:
self._val = int(Decimal(base) * Decimal(10 ** expo))
else:
self._val = int(Decimal(val))
elif type.type == 'bool':
Expand Down
2 changes: 1 addition & 1 deletion slither/tools/erc_conformance/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def parse_args():
:return: Returns the arguments for the program.
"""
parser = argparse.ArgumentParser(
description="Check the ERC 20 conformance", usage="slither-erc project contractName"
description="Check the ERC 20 conformance", usage="slither-check-erc project contractName"
)

parser.add_argument("project", help="The codebase to be tested.")
Expand Down