Skip to content

Latest commit

 

History

History
18 lines (13 loc) · 1.01 KB

SWC-129.md

File metadata and controls

18 lines (13 loc) · 1.01 KB

Title

Typographical Error

Relationships

CWE-480: Use of Incorrect Operator

Description

A typographical error can occur for example when the intent of a defined operation is to sum a number to a variable (+=) but it has accidentally been defined in a wrong way (=+), introducing a typo which happens to be a valid operator. Instead of calculating the sum it initializes the variable again.

The unary + operator is deprecated in new solidity compiler versions.

Remediation

The weakness can be avoided by performing pre-condition checks on any math operation or using a vetted library for arithmetic calculations such as SafeMath developed by OpenZeppelin.

References