...
Truncating strings can lead to a loss of data.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
STR03-C | Medium | Probable | Medium | P8 | L2 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
CodeSonar |
| MISC.MEM.NTERM | No Space For Null Terminator | ||||||
Compass/ROSE |
Could detect violations in the following manner: all calls to | ||||||||
Klocwork |
|
LDRA tool suite |
| 115 S, 44 S | Partially implemented | ||||||
Parasoft C/C++test |
|
|
| BD-PB-OVERNZT |
Polyspace Bug Finder | R2016a | Buffer overflow from incorrect string format specifier | String format specifier causes buffer argument of standard library functions to overflow |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
SEI CERT C++ Coding Standard | VOID 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 |
Bibliography
[Seacord 2013] | Chapter 2, "Strings" |
...
...