Skip to content
uencoder

Integer Overflow

An integer overflow occurs when an arithmetic result exceeds the representable range of the type and wraps around, potentially causing undersized buffer allocations or logic errors.

Purpose

To understand memory allocation and bounds-check bypasses caused by integer overflow; a common defect in C/C++ and cryptographic implementations.

Mechanism

Signed integer overflow is undefined behavior (C/C++); unsigned integers wrap modulo 2^n. For example, size_t len = a + b wraps to a small value if a+b exceeds SIZE_MAX, so malloc(len) under-allocates and subsequent writes overflow.

Use cases

  • Memory allocation safety
  • Crypto implementation audit
  • Bounds check bypass

Related tools

References