Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The C standard, Section 6.5.5 [ISO/IEC 9899:2011], states:

The result of the / operator is the quotient from the division of the first operand by the second; the result of the % operator is the remainder. In both operations, if the value of the second operand is zero, the behavior is undefined.

...

CERT C++ Secure Coding Standard: INT10-CPP. Do not assume a positive remainder when using the % operator

ISO/IEC 9899:2011 Section 6.5.5, "Multiplicative operators"

The CERT Oracle Secure Coding Standard for Java: NUM02-J. Ensure that division and modulo operations do not result in divide-by-zero errors

ISO/IEC 9899:2011 Section 6.5.5, "Multiplicative operators"

MITRE CWE: CWE-682, "Incorrect calculation"

...