Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added that C++ strings need no null terminator

Copying data to a buffer that is not large enough to hold that data results in a buffer overflow. Buffer overflows occur frequently when manipulating strings [Seacord 2013]. To prevent such errors, either limit copies through truncation or, preferably, ensure that the destination is of sufficient size to hold the character data to be copied and the null-termination character. This . C strings require a null character to indicate the end o the string, while the C++ basic_string template requires no such character. This rule is a C++-specific instance of STR31-C. Guarantee that storage for strings has sufficient space for character data and the null terminator.

...