String does not terminate with null character
This defect occurs when a string does not have enough
space to terminate with a null character '\0'.
This defect applies only for projects in C.
A buffer overflow can occur if you copy a string to an array without assuming the implicit null terminator.
If you initialize a character array with a literal, avoid specifying the array bounds.
char three[] = "THREE";
If the issue occurs after initialization, you might have to increase the size of the array by one to account for the null terminator.
In certain circumstances, you might want to initialize the character array with a sequence of characters instead of a string. In this situation, add comments to your result or code to avoid another review. See Address Polyspace Results Through Bug Fixes or Justifications.
| Group: Programming |
| Language: C |
| Default: On for handwritten code, off for generated code |
Command-Line Syntax: MISSING_NULL_CHAR |
| Impact: Low |
| CWE ID: 170 |