Versions Compared

Key

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

...

Wiki Markup
The type {{size_t}} generally covers the entire address space. ISO/IEC TR 24731-1-2007 introduces a new type {{rsize_t}}, defined to be {{size_t}} but explicitly used to hold the size of a single object \[[Meyers 2004|AA. Bibliography#Meyers 2004]\]. In code that documents this purpose by using the type {{rsize_t}}, the size of an object can be checked to verify that it is no larger than {{RSIZE_MAX}}, the maximum size of a normal single object, which provides additional input validation for library functions. See guidelinerecommendation [STR07-C. Use TR 24731 for remediation of existing string manipulation code] for additional discussion of TR 24731-1.

...

Wiki Markup
The unsigned {{n}} may contain a value greater than {{INT_MAX}}.  Assuming quiet wraparound on signed overflow, the loop executes {{n}} times because the comparison {{i < n}} is an unsigned comparison. Once {{i}} is incremented beyond {{INT_MAX}}, {{i}} takes on negative values starting with ({{INT_MIN}}).  Consequently, the memory locations referenced by {{p\[i\]}} precede the memory referenced by {{p}} and a write-outside-array bounds occurs.

...

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

Related Guidelines

CERT C++ Secure Coding Standard: INT01-CPP. Use rsize_t or size_t for all integer values representing the size of an object

...

Wiki Markup\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section ,Section 7.17, "Common definitions {{<stddef.h>}}", Section 7.20.3, "Memory management functions" \[[

ISO/IEC TR 24731-1:2007

Bibliography

Wiki Markup
|AA. Bibliography#ISO/IEC TR 24731-1-2007]\]
\[[Meyers 2004|AA. Bibliography#Meyers 2004]\]

...