Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: REM Cost Reform

If one definition affects another, a relation exists between constants, you should encode the relationship in the definition; do definitions. Do not give two independent definitions. A corollary of this recommendation is not to encode transitory relationships in definitions, because a maintainer may fail to preserve that relationship when modifying the code. As a corollary, do not encode an impermanent or false relationship between constants, because future modifications may result in an incorrect definition for the dependent constant.

Noncompliant Code Example

...

Code Block
bgColor#FFcccc
langc
enum { ADULT_AGE=18 };

/* Misleading,; relationship established when none exists */
enum { ALCOHOL_AGE=ADULT_AGE+3 };

...

This compliant solution does not assume a relationship when where none exists:

Code Block
bgColor#ccccff
langc
enum { ADULT_AGE=18 };
enum { ALCOHOL_AGE=21 };

Risk Assessment

Failing to properly encode relationships in constant definitions may lead to the introduction of defects during maintenance. These defects could potentially result in vulnerabilities, for example, if the affected constants were used for allocating or accessing memory.

Recommendation

Severity

Likelihood

Detectable

Remediation Cost

Repairable

Priority

Level

DCL08-C

Low

low

Unlikely

unlikely

No

high

No

P1

L3

Automated Detection

Tool

Version

Checker

Description

LDRA tool suite

Include PageLDRA_VLDRA_V

387 S

Partially implemented

Related Vulnerabilities

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

Related Guidelines

[Plum 1985]Rule 1-4

...


...

Image Modified Image Modified Image Modified