...
The strcpy_s()
function defined in C11 Annex K [ISO/IEC 9899:2011] provides additional safeguards, including accepting the size of the destination buffer as an additional argument. (See STR07-C. Use the bounds-checking interfaces for remediation of existing string manipulation code.) Also, strnlen_s()
accepts a maximum-length argument for strings that may not be null-terminated.
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
CodeSonar |
| MISC.MEM.NTERM | No Space For Null Terminator | ||||||
|
| Could detect violations in the following manner: all calls to | |||||||
5.0 |
| Can detect violations of this rule with CERT C Rule Pack | |||||||
| NNTS |
| |||||||
| 115 S | Fully implemented |
...
Related Guidelines
CERT C++ Secure Coding Standard | STR03-CPP. Do not inadvertently truncate a null-terminated character array |
ISO/IEC TR 24772:2013 | String Termination [CJM] |
MITRE CWE | CWE-170, Improper null termination CWE-464, Addition of data structure sentinel |
...