Skip to content

Commit 93a773c

Browse files
Add comments where intention was unclear
1 parent 6ad3660 commit 93a773c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

c/cert/src/rules/CON34-C/AppropriateThreadObjectStorageDurations.ql

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ where
3939
)
4040
)
4141
or
42-
// TODO: Remove/replace with tss_t type check, see #801.
42+
// TODO: This case is handling threadlocals in a useful way that's not intended to be covered
43+
// by the rule. See issue #801. The actual rule should expect no tss_t objects is used, and
44+
// this check that this is initialized doesn't seem to belong here. However, it is a useful
45+
// check in and of itself, so we should figure out if this is part of an optional rule we
46+
// haven't yet implemented and move this behavior there.
4347
exists(TSSGetFunctionCall tsg |
4448
TaintTracking::localTaint(DataFlow::exprNode(tsg), DataFlow::exprNode(arg)) and
4549
not exists(TSSSetFunctionCall tss, DataFlow::Node src |

c/common/src/codingstandards/c/Objects.qll

+5
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,14 @@ abstract class ObjectIdentityBase extends Element {
106106
exists(Expr subobject |
107107
subobject = getASubobjectAccess() and
108108
(
109+
// Holds for address-of expressions.
109110
result = any(AddressOfExpr e | e.getOperand() = subobject)
110111
or
112+
// Holds for array-to-pointer conversions, which evaluate to a usable subobject address.
111113
exists(ArrayToPointerConversion c | c.getExpr() = subobject) and
114+
// Note that `arr[x]` has an array-to-pointer conversion, and returns the `x`th item by
115+
// value, not the address of the `x`th item. Therefore, exclude `arr` if `arr` is part of
116+
// an expression `arr[x]`.
112117
not exists(ArrayExpr a | a.getArrayBase() = subobject) and
113118
result = subobject
114119
)

0 commit comments

Comments
 (0)