Versions Compared

Key

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

...

This compliant solution eliminates the possibility of undefined behavior resulting from a left shift operation on integers, it also uses unsigned integers in accordance with INT13-AC. Use bitwise operators only on unsigned operands. Smaller sized integers are promoted according to the integer promotion rules (see INT02-C. Understand integer conversion rules).

...

Making assumptions about whether a right shift is implemented as an arithmetic (signed) shift or a logical (unsigned) shift can also lead to vulnerabilities (see INT13-AC. Use bitwise operators only on unsigned operands).

Compliant Solution (Right Shift)

...