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 062006|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.

Other Languages

Related Guidelines

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

Bibliography

Wiki Markup
\[[Dowd 062006|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 042004|AA. Bibliography#Sloss 04]\] Section 5.7, "Structure Arrangement"

...