...
Code Block | ||||
---|---|---|---|---|
| ||||
char *source = "0123456789abcdef"; char ntbs[NTBS_SIZE]; /* ... */ if (source) { if (strlen(source) < sizeof(ntbs)) { strcpy(ntbs, source); } else { /* handleHandle string too large condition */ } } else { /* handleHandle NULL string condition */ } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
char *source; char a[NTBS_SIZE]; /* ... */ if (source) { errno_t err = strncpy_s(a, sizeof(a), source, 5); if (err != 0) { /* Handle error */ } } else { /* handleHandle NULL string condition */ } |
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Compass/ROSE |
|
| Can detect some violations of this rule. | ||||||
Coverity | 6.5 | STRING_NULL | Fully Implemented. | ||||||
| NNTS |
| |||||||
| 600 S | Fully implemented. |
...
Bibliography
[Schwarz 2005] | |
[Seacord 2005a2013] | Chapter 2, "Strings" |
[Viega 2005] | Section 5.2.14, "Miscalculated NULL Termination" |
...