...
In this non-compliant example, the first declaration of the identifier x would be classified as externally linked. The second declaration is internally linked. Future use of this identifier can cause undefined behavior.int x; // externally linked
Code Blockpanel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
int x; // externally linked int main() { static int x; // internally linked ... // future use of identifier x can cause undefined behavior. } |
Compliant Solution
In this compliant solution, more descriptive identifier names are used, so as to avoid this problem.int externalInt; // externally linked
Code Blockpanel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
int external_x; // externally linked int main() { static intinternalInt internal_x; // internally linked ... } |
Risk Assessment
Use of an identifier classified as both internally and externally linked causes undefined behavior in the program. However, it would be highly unlikely that an attacker could exploit this behavior to run arbitrary code.
...