Integer overflow Medium

An integer overflow might occur when the input or resulting value is too large to store in an associated representation. This can result in a critical security issue when it is used to make security decisions.

Detector ID
typescript/integer-overflow@v1.0
Category
Common Weakness Enumeration (CWE) external icon

Noncompliant example

1function integerOverflowNoncompliant() {
2  // Noncompliant: bigint is assigned to a variable.
3  var max: number = 154327115334273650000012748329;
4}

Compliant example

1function integerOverflowCompliant() {
2  // Compliant: number is passed in BigInt() method is appended to an integer which makes it a bigint.
3  var max: BigInt = BigInt(154327115334273650000012748329);
4}