Skip to content

Commit 976adc3

Browse files
committed
C++: Fixup queries to keep the old results.
1 parent ef2caa3 commit 976adc3

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

cpp/ql/src/Likely Bugs/Format/NonConstantFormat.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ predicate cannotContainString(Type t, boolean isIndirect) {
6868

6969
predicate isNonConst(DataFlow::Node node, boolean isIndirect) {
7070
exists(Expr e |
71-
e = node.asExpr() and isIndirect = false
71+
e = [node.asExpr(), node.asDefinition()] and isIndirect = false
7272
or
73-
e = node.asIndirectExpr() and isIndirect = true
73+
e = [node.asIndirectExpr(), node.asIndirectDefinition()] and isIndirect = true
7474
|
7575
exists(FunctionCall fc | fc = e |
7676
not (

cpp/ql/src/Security/CWE/CWE-190/IntegerOverflowTainted.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,15 @@ predicate isSource(FS::FlowSource source, string sourceType) { sourceType = sour
3535

3636
predicate isSink(DataFlow::Node sink, string kind) {
3737
exists(Expr use |
38-
use = sink.asExpr() and
3938
not use.getUnspecifiedType() instanceof PointerType and
4039
outOfBoundsExpr(use, kind) and
4140
not inSystemMacroExpansion(use)
41+
|
42+
if
43+
sink.asDefinition() instanceof CrementOperation or
44+
sink.asDefinition() instanceof AssignOperation
45+
then use = sink.asDefinition()
46+
else use = sink.asExpr()
4247
)
4348
}
4449

cpp/ql/src/Security/CWE/CWE-190/TaintedAllocationSize.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ module TaintedAllocationSizeConfig implements DataFlow::ConfigSig {
6060
predicate isSink(DataFlow::Node sink) { allocSink(_, sink) }
6161

6262
predicate isBarrier(DataFlow::Node node) {
63-
exists(Expr e | e = node.asExpr() |
63+
exists(Expr e | e = [node.asExpr(), node.asDefinition()] |
6464
// There can be two separate reasons for `convertedExprMightOverflow` not holding:
6565
// 1. `e` really cannot overflow.
6666
// 2. `e` isn't analyzable.

0 commit comments

Comments
 (0)