Versions Compared

Key

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

...

Wiki Markup
This noncompliant code example assumes that the size of {{struct buffer}} is equal to the sum of the size of its individual components, which may not be the case  \[[Dowd 2006|AA. Bibliography#Dowd 06]\]. The size of {{struct buffer}} may actually be larger due to structure padding.

...

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

Related Guidelines

CERT C++ Secure Coding Standard: EXP03-CPP. Do not assume the size of a class or struct is the sum of the sizes of its members

ISO/IEC 9899:1999 Section 6.7.2.1, "Structure and union specifiers"

Bibliography

Wiki Markup
\[[Dowd 2006|AA. Bibliography#Dowd 06]\] Chapter 6, "C Language Issues" (Structure Padding 284-287)
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.7.2.1, "Structure and union specifiers"
\[[Sloss 2004|AA. Bibliography#Sloss 04]\] Section 5.7, "Structure Arrangement"

...