Versions Compared

Key

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

...

Incorrectly using the sizeof operator to determine the size of an array can result in a buffer overflow, allowing the execution of arbitrary code.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

ARR01-C

High

Probable

Low

P18

L1

Automated Detection

Tool

Version

Checker

Description

Compass/ROSE

 

 



Can detect violations of the recommendation but cannot distinguish between incomplete array declarations and pointer declarations

Klocwork
Include Page
Klocwork_V
Klocwork_V
CWARN.MEMSET.SIZEOF.PTRFully implemented
LDRA tool suite
Include Page
LDRA_V
LDRA_V

401 S

Fully implemented

Parasoft C/C++test
Include Page
c:
Parasoft_V
c:
Parasoft_V
PB-32Fully implemented
Polyspace Bug FinderR2016aPossible misuse of sizeof

Use of sizeof operator can cause unintended results

Splint
Include Page
Splint_V
Splint_V

 



PVS-Studio6.22V511, V512, V514, V568, V579, V604, V697General analysis rule set
 

Related Vulnerabilities

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

...

Key here (explains table format and definitions)

Taxonomy

Taxonomy item

Relationship

CERT CCTR01-CPP. Do not apply the sizeof operator to a pointer when taking the size of an arrayPrior to 2018-01-12: CERT: Unspecified Relationship
CWE 2.11CWE-467, Use of sizeof() on a pointer typePrior to 2018-01-12: CERT:
ISO/IEC TS 17961Taking the size of a pointer to determine the size of the pointed-to type [sizeofptr]Prior to 2018-01-12: CERT: Unspecified Relationship
MITRE CWECWE-569Prior to 2018-01-12:
MITRE CWECWE-783Prior to 2018-01-12:

Bibliography

[Drepper 2006]Section 2.1.1, "Respecting Memory Bounds"
[ISO/IEC 9899:2011]Subclause 6.5.3.4, "The sizeof and _Alignof Operators"

...


...