Versions Compared

Key

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

...

Also, consider using the sprintf_s() function, defined in ISO/IEC TR 24731-1, instead of snprintf() to provide some additional checks. (See STR07-C. Use the bounds-checking interfaces for remediation of existing string manipulation code.)

Exceptions

INT13-EX1: When used as bit flags, it is acceptable to use preprocessor macros as arguments to the & and | operators even if the value is not explicitly declared as unsigned.

...

Tool

Version

Checker

Description

Compass/ROSE

 

 

Can detect violations of this rule. In particular, it flags bitwise operations that involved variables not declared with unsigned type

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

CC2.INT13

Fully implemented

Fortify SCA

5.0

 

Can detect violations of this recommendation with the CERT C Rule Pack

LDRA tool suite

Include Page
LDRA_V
LDRA_V

50 S
120 S
331 S

Fully implemented

PRQA QA-C
Include Page
PRQA QA-C_Vv
PRQA QA-C_V

0502
4130
4131

v
4532, 4533, 4534, 4543, 4544Fully implemented

Splint

Include Page
Splint_V
Splint_V

 

 

...

Related Guidelines

CERT C++ Secure Coding StandardINT13-CPP. Use bitwise operators only on unsigned operands
ISO/IEC TR 24772:2013Bit Representations [STR]
Arithmetic Wrap-around Error [FIF]
Sign Extension Error [XZI]
MITRE CWECWE-682, Incorrect calculation

...