...
Code Block | ||||
---|---|---|---|---|
| ||||
/* In another source file */
#include <string.h>
void copy(char *dst, const char *src) {
if (strcpy(dst, src) == 0) {
/* Report error */
}
}
/* Copy prototype in scope in this source file */
void copy(char *dst, const char *src);
void g(const char *s) {
char buf[20];
copy(buf, s);
/* ... */
}
|
...
Code Block | ||||
---|---|---|---|---|
| ||||
/* In another source file */ void buginf(const char *fmt, ...) { /* ... */ } /* In this source file --, no buginf prototype in scope */ void buginf(); void h(void) { buginf("bug in function %s, line %d\n", __func__, __LINE__); /* Violation */ /* ... */ } |
...
Code Block | ||||
---|---|---|---|---|
| ||||
/* In another source file */ long f(long x) { return x < 0 ? -x : x; } /* In this source file, -- no f prototype in scope */ int g(int x) { return f(x); /* Violation */ } |
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
EXP37-C | mediumMedium | probableProbable | highHigh | P4 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Compass/ROSE | Can detect some violations of this rule. In particular, it ensures that all calls to | ||||||||
| CC2.EXP37 | Partially implemented | |||||||
EDG | |||||||||
Fortify SCA | 5.0 | ||||||||
GCC |
| Can detect violation of this rule when the | |||||||
| 41 D | Partially implemented | |||||||
PRQA QA-C |
| 3001 0674(C) | Partially implemented |
...