Versions Compared

Key

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

Division and modulo operations are susceptible to divide-by-zero errors. According to C11, Section 6.5.5, para. 5  [ISO/IEC 9899:2011],

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.

...

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V

43 D
248 S

Partially implemented.
Fortify SCAV. 5.0 

Can detect violations of this rule with CERT C Rule Pack.

Compass/ROSE

  

Can detect some violations of this rule. In particular, it ensures that all operations involving division or modulo are preceded by a check ensuring that the second operand is nonzero.

...

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  Section 6.5.5, "Multiplicative operators"

...