Versions Compared

Key

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

...

Code Block
bgColor#ffcccc
langc
int value;

if (scanf("%d", &value) == 1) {
  if (value & 0x1 != 0) {
    /* Do something if value is odd. */
  }
}

Compliant Solution

The same thing can be achieved compliantly using the modulo operator:

Code Block
bgColor#ccccff
langc
int value;

if (scanf("%d", &value) == 1) {
  if (value % 2 != 0) {
    /* Do something if value is odd. */
  }
}

Risk Assessment

Incorrect assumptions about integer representation can lead to execution of unintended code branches and other unexpected behavior.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

INT16-C

mediumMedium

unlikelyUnlikely

highHigh

P2

L3

 

...