Skip to content

Commit edca7d1

Browse files
committed
PRE31-C: Update metadata and docs
* Add an implementation scope * Add qldocs * Update description.
1 parent ac338c5 commit edca7d1

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

c/cert/src/rules/PRE31-C/SideEffectsInArgumentsToUnsafeMacros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ Search for [vulnerabilities](https://wiki.sei.cmu.edu/confluence/display/c/BB.+D
202202

203203
## Implementation notes
204204

205-
None
205+
This implementation only considers ++ and function call side effects. Due to the textual nature of macro expansion it is not always possible to determine accurately whether a side-effect was produced by a particular argument, and this may cause both false positives and false negatives. The query does not consider the case where a macro argument including a side-effect is never evaluated.
206206

207207
## References
208208

c/cert/src/rules/PRE31-C/SideEffectsInArgumentsToUnsafeMacros.ql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @id c/cert/side-effects-in-arguments-to-unsafe-macros
33
* @name PRE31-C: Avoid side effects in arguments to unsafe macros
44
* @description Macro arguments can be expanded multiple times which can cause side-effects to be
5-
* evaluated multiple times.
5+
* evaluated multiple times leading to unexpected program behavior.
66
* @kind problem
77
* @precision low
88
* @problem.severity error
@@ -20,6 +20,9 @@ import codingstandards.cpp.sideeffect.DefaultEffects
2020
import codingstandards.cpp.sideeffect.Customizations
2121
import semmle.code.cpp.valuenumbering.HashCons
2222

23+
/**
24+
* Add side-effecting functions to the default set of side-effects.
25+
*/
2326
class FunctionCallEffect extends GlobalSideEffect::Range {
2427
FunctionCallEffect() {
2528
exists(Function f |
@@ -44,6 +47,9 @@ class FunctionCallEffect extends GlobalSideEffect::Range {
4447
}
4548
}
4649

50+
/**
51+
* Add crement operations to the default set of side-effects.
52+
*/
4753
class CrementEffect extends LocalSideEffect::Range {
4854
CrementEffect() { this instanceof CrementOperation }
4955
}

rule_packages/c/SideEffects4.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
},
77
"queries": [
88
{
9-
"description": "Macro arguments can be expanded multiple times which can cause side-effects to be evaluated multiple times.",
9+
"description": "Macro arguments can be expanded multiple times which can cause side-effects to be evaluated multiple times leading to unexpected program behavior.",
1010
"kind": "problem",
1111
"name": "Avoid side effects in arguments to unsafe macros",
1212
"precision": "low",
1313
"severity": "error",
1414
"short_name": "SideEffectsInArgumentsToUnsafeMacros",
1515
"tags": [
1616
"correctness"
17-
]
17+
],
18+
"implementation_scope": {
19+
"description": "This implementation only considers ++ and function call side effects. Due to the textual nature of macro expansion it is not always possible to determine accurately whether a side-effect was produced by a particular argument, and this may cause both false positives and false negatives. The query does not consider the case where a macro argument including a side-effect is never evaluated."
20+
}
1821
}
1922
],
2023
"title": "Avoid side effects in arguments to unsafe macros"

0 commit comments

Comments
 (0)