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 C11the C Standard, Section 6.5.5, para. paragraph 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.

...

LDRA_V

Tool

Version

Checker

Description

LDRA tool suite

Include Page

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.

Fortify SCA5.0 

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

LDRA tool suite

Include Page
LDRA_V
LDRA_V

43 D
248 S

Partially implemented.
PRQA QA-C
Include Page
PRQA_V
PRQA_V

2830 (C)
2831 (D)
2832 (A)
2833 (S)
2834 (P)

Fully implemented.

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

...

...

...

(Draft) Dividing by zero [divzero]
MITRE CWE

...

...

Divide by zero

...

Bibliography

[Seacord 2005]Chapter 5, "Integers"
[Warren 2002]Chapter 2, "Basics"

...