Versions Compared

Key

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

...

Tool

Version

Checker

Description

Astrée
Include Page
Astrée_V
Astrée_V
 Supported, but no explicit checker
CodeSonar
Include Page
CodeSonar_V
CodeSonar_V

BADFUNC.RANDOM.RAND
BADFUNC.TEMP.TMPNAM
BADFUNC.TTYNAME

Use of rand (includes check for uses of srand())
Use of tmpnam (includes check for uses of tmpnam_r())
Use of ttyname

Compass/ROSE

 

 

A module written in Compass/ROSE can detect violations of this rule

LDRA tool suite 
Include Page
LDRA_V
LDRA_V
44 SPartially Implemented
Parasoft C/C++test9.5SECURITY-25 
PRQA QA-C++
Include Page
cplusplus:PRQA QA-C++_V
cplusplus:PRQA QA-C++_V
5021 

Related Guidelines

Key here (explains table format and definitions)

 

Taxonomy

Taxonomy item

Relationship

CERT C Secure Coding StandardERR30-C. Set errno to zero before calling a library function known to set errno, and check errno only after the function returns a value indicating failurePrior to 2018-01-12: CERT: Unspecified Relationship
CERT CSEI CERT C++ Coding StandardCON00-CPP. Avoid assuming functions are thread safe unless otherwise specifiedPrior to 2018-01-12: CERT: Unspecified Relationship
CWE 2.11CWE-3302017-06-28: CERT: Partial overlap
CWE 2.11CWE-3772017-06-28: CERT: Partial overlap
CWE 2.11CWE-6762017-05-18: CERT: Rule subset of CWE

CERT-CWE Mapping Notes

Key here for mapping notes

CWE-330 and CON33-C

Independent( MSC30-C, MSC32-C, CON33-C)

Intersection( CWE-330, CON33-C) =

  • Use of rand() or srand() from multiple threads, introducing a race condition.

CWE-330 – CON33-C =

  • Use of rand() or srand() without introducing race conditions

  • Use of other dangerous functions

CON33-C – CWE-330 =

  • Use of other global functions (besides rand() and srand()) introducing race conditions

CWE-377 and CON33-C

Intersection( CWE-377, CON33-C) =

  • Use of tmpnam() from multiple threads, introducing a race condition.

CWE-377 – CON33-C =

  • Insecure usage of tmpnam() without introducing race conditions

  • Insecure usage of other functions for creating temporary files (see CERT recommendation FIO21-C for details)

CON33-C – CWE-377 =

  • Use of other global functions (besides tmpnam()) introducing race conditions

CWE-676 and CON33-C

  • Independent( ENV33-C, CON33-C, STR31-C, EXP33-C, MSC30-C, ERR34-C)

  • CON33-C lists standard C library functions that manipulate global data (e.g., locale()), that can be dangerous to use in a multithreaded context.

  • CWE-676 = Union( CON33-C, list) where list =

  • Invocation of the following functions without introducing a race condition:

  • rand(), srand(, getenv(), getenv_s(), strtok(), strerror(), asctime(), ctime(), localtime(), gmtime(), setlocale(), ATOMIC_VAR_INIT, atomic_init(), tmpnam(), mbrtoc16(), c16rtomb(), mbrtoc32(), c32rtomb()

  • Invocation of other dangerous functions

Bibliography

[IEEE Std 1003.1:2013]Section 2.9.1, "Thread Safety"
[ISO/IEC 9899:2011]

Subclause 7.24.6.2, "The strerror Function" 

[Open Group 1997b]Section 10.12, "Thread-Safe POSIX.1 and C-Language Functions"

...