...
| Code Block | ||
|---|---|---|
| ||
#include <signal.h> size_t i; void handler() { i = 0; } int main(void) { signal(SIGINT, handler); i = 1; while (i) { /* do something */ } } |
Compliant Solution
i is accessed for every iteration of the while loop.
| Code Block | ||
|---|---|---|
| ||
#include <signal.h> volatile size_t i; void handler() { i = 0; } int main(void) { signal(SIGINT, handler); i = 1; while (i) { /* do something */ } } |
Risk Assessment
In addition to incorrect optimizations, this can cause race conditions, resulting in an inconsistent state.
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
|---|---|---|---|---|---|
DCL34-C | 2 (medium) | 2 (probable) | 3 2 (lowmedium) | P12 P6 | L1 L2 |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...