...
| Code Block | ||||
|---|---|---|---|---|
| ||||
int buf[INTBUFSIZE];
int *buf_ptr = buf;
while (havedata() && buf_ptr < &buf[INTBUFSIZE]) {
*buf_ptr++ = parseint(getdata());
}
|
...
Recommendation | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
EXP08-C | High | Probable | No | HighNo | P6 | L2 |
Automated Detection
Tool | Version | Checker | Description | |||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| Supported | , but no explicit checker: Astrée reports potential runtime errors resulting from invalid pointer arithmetics. | |||||||||||||||||
| CodeSonar |
| LANG.STRUCT.PARITH | Pointer arithmetic | |||||||||||||||||
| Helix QAC |
| C0488, C2930, C2931, C2932, C2933 | ||||||||||||||||||
| Klocwork |
| ABV.ITERATOR ABV.GENERAL ABV.GENERAL.MULTIDIMENSION | ||||||||||||||||||
| LDRA tool suite |
| 45 D | Partially implemented | |||||||||||||||||
| Parasoft C/C++test |
| MISRA-101 BD-PB-ARRAY | Checks all array access, not just pointer arithmeticCERT_C-EXP08-a | Pointer arithmetic should not be used | ||||||||||||||||
| Parasoft Insure++ | Runtime analysis | for over- or under- read or write|||||||||||||||||||
| PC-lint Plus |
| 416 | Partially supported | |||||||||||||||||
| Polyspace Bug Finder |
| R2016a | Implicit scaling in pointer arithmetic might be ignored Pointer dereferenced outside its bounds | PRQA QA-C | ||||||||||||||||
| Include Page | PRQA QA-C_v | PRQA QA-C_v | 0488, 2930, 2931, 2932, 2933, 2934 |
| Checks for:
Rec. fully supported. | |||||||||||||||
| PVS-Studio |
| PVS-Studio | 6.22 | V503, V520, V574, V600, V613, V619, V620, V643, V650, V687, V769, V1004 | ||||||||||||||||
| Security Reviewer - Static Reviewer |
| C37 | Fully implemented |
How long is 4 yards plus 3 feet? It is obvious from elementary arithmetic that any answer involving 7 is wrong, as the student did not take the units into account. The right method is to convert both numbers to reflect the same units.
...