Skip to content

Commit 5a72498

Browse files
Merge commit '17b5cef3498a4f21fedc9db5736c2540bdc5dec8' into codeql/upgrade-to-2.23.9
2 parents a9b93b3 + 17b5cef commit 5a72498

188 files changed

Lines changed: 1384 additions & 772 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

c/cert/src/rules/ARR32-C/VariableLengthArraySizeNotInValidRange.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import cpp
2121
import codingstandards.c.cert
2222
import codingstandards.cpp.Overflow
23-
import semmle.code.cpp.dataflow.TaintTracking
23+
import semmle.code.cpp.dataflow.new.TaintTracking
2424

2525
/**
2626
* Gets the maximum size (in bytes) a variable-length array

c/cert/src/rules/ARR37-C/DoNotUsePointerArithmeticOnNonArrayObjectPointers.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import cpp
2020
import codingstandards.c.cert
21-
import semmle.code.cpp.dataflow.DataFlow
21+
import semmle.code.cpp.dataflow.new.DataFlow
2222
import NonArrayPointerToArrayIndexingExprFlow::PathGraph
2323

2424
/**

c/cert/src/rules/ARR39-C/DoNotAddOrSubtractAScaledIntegerToAPointer.ql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import cpp
2020
import codingstandards.c.cert
2121
import codingstandards.cpp.types.Pointers
22-
import semmle.code.cpp.dataflow.TaintTracking
22+
import semmle.code.cpp.dataflow.new.TaintTracking
2323
import ScaledIntegerPointerArithmeticFlow::PathGraph
2424

2525
/**
@@ -61,9 +61,11 @@ class ScaledIntegerExpr extends Expr {
6161
ScaledIntegerExpr() {
6262
not this.getParent*() instanceof ArrayCountOfExpr and
6363
(
64-
this.(SizeofExprOperator).getExprOperand().getType().getSize() > 1
64+
exists(this.getValue()) and
65+
this.getAChild*().(SizeofExprOperator).getExprOperand().getType().getSize() > 1
6566
or
66-
this.(SizeofTypeOperator).getTypeOperand().getSize() > 1
67+
exists(this.getValue()) and
68+
this.getAChild*().(SizeofTypeOperator).getTypeOperand().getSize() > 1
6769
or
6870
this instanceof OffsetOfExpr
6971
)

c/cert/src/rules/CON30-C/CleanUpThreadSpecificStorage.ql

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,31 @@
1919

2020
import cpp
2121
import codingstandards.c.cert
22-
import codingstandards.cpp.Concurrency
23-
import semmle.code.cpp.dataflow.DataFlow
22+
import codingstandards.cpp.ConcurrencyNew
23+
import semmle.code.cpp.dataflow.new.DataFlow
24+
25+
newtype Direction =
26+
Incoming() or
27+
Outgoing()
28+
29+
predicate isSource(DataFlow::Node node, Direction d) {
30+
exists(TSSCreateFunctionCall tsc, Expr e |
31+
// the only requirement of the source is that at some point
32+
// it refers to the key of a create statement
33+
e.getParent*() = tsc.getKey()
34+
|
35+
d = Outgoing() and
36+
e = [node.asExpr(), node.asDefiningArgument()]
37+
or
38+
d = Incoming() and
39+
e = [node.asExpr(), node.asIndirectArgument()]
40+
)
41+
}
2442

2543
module TssCreateToTssDeleteConfig implements DataFlow::ConfigSig {
26-
predicate isSource(DataFlow::Node node) {
27-
exists(TSSCreateFunctionCall tsc, Expr e |
28-
// the only requirement of the source is that at some point
29-
// it refers to the key of a create statement
30-
e.getParent*() = tsc.getKey() and
31-
(e = node.asDefiningArgument() or e = node.asExpr())
32-
)
33-
}
44+
predicate isSource(DataFlow::Node node) { isSource(node, Outgoing()) }
45+
46+
predicate isBarrierIn(DataFlow::Node node) { isSource(node, Incoming()) }
3447

3548
predicate isSink(DataFlow::Node node) {
3649
exists(TSSDeleteFunctionCall tsd, Expr e |

c/cert/src/rules/CON33-C/RaceConditionsWhenUsingLibraryFunctions.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import cpp
2020
import codingstandards.c.cert
21-
import codingstandards.cpp.Concurrency
21+
import codingstandards.cpp.ConcurrencyNew
2222

2323
from ThreadedCFN node
2424
where

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import cpp
2121
import codingstandards.c.cert
2222
import codingstandards.c.Objects
23-
import codingstandards.cpp.Concurrency
24-
import semmle.code.cpp.dataflow.DataFlow
23+
import codingstandards.cpp.ConcurrencyNew
24+
import semmle.code.cpp.dataflow.new.DataFlow
2525
import semmle.code.cpp.commons.Alloc
2626

2727
from C11ThreadCreateCall tcc, Expr arg
@@ -53,6 +53,7 @@ where
5353
not exists(TSSSetFunctionCall tss, DataFlow::Node src |
5454
// there should be dataflow from somewhere (the same somewhere)
5555
// into each of the first arguments
56+
exists(Expr e | e = src.asDefinition() or e = src.asDefiningArgument()) and
5657
DataFlow::localFlow(src, DataFlow::exprNode(tsg.getArgument(0))) and
5758
DataFlow::localFlow(src, DataFlow::exprNode(tss.getArgument(0)))
5859
)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
import cpp
2222
import codingstandards.c.cert
23-
import codingstandards.cpp.Concurrency
24-
import semmle.code.cpp.dataflow.DataFlow
23+
import codingstandards.cpp.ConcurrencyNew
24+
import semmle.code.cpp.dataflow.new.DataFlow
2525

2626
from TSSGetFunctionCall tsg, ThreadedFunction tf
2727
where
@@ -31,7 +31,8 @@ where
3131
// however, there does not exist a proper sequencing.
3232
not exists(TSSSetFunctionCall tss, DataFlow::Node src |
3333
// there should be dataflow from somewhere (the same somewhere)
34-
// into each of the first arguments
34+
// into each of the first argument
35+
exists(Expr e | e = src.asDefinition() or e = src.asDefiningArgument()) and
3536
DataFlow::localFlow(src, DataFlow::exprNode(tsg.getArgument(0))) and
3637
DataFlow::localFlow(src, DataFlow::exprNode(tss.getArgument(0)))
3738
)

c/cert/src/rules/CON37-C/DoNotCallSignalInMultithreadedProgram.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import cpp
2121
import codingstandards.c.cert
22-
import codingstandards.cpp.Concurrency
22+
import codingstandards.cpp.ConcurrencyNew
2323

2424
from FunctionCall fc
2525
// This should only be applied in the context of a multi-threaded program (since

c/cert/src/rules/CON40-C/AtomicVariableTwiceInExpression.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import cpp
2121
import codingstandards.c.cert
22-
import codingstandards.cpp.Concurrency
22+
import codingstandards.cpp.ConcurrencyNew
2323

2424
from MacroInvocation mi, Variable v, Locatable whereFound
2525
where

c/cert/src/rules/CON41-C/WrapFunctionsThatCanFailSpuriouslyInLoop.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import cpp
2121
import codingstandards.c.cert
22-
import codingstandards.cpp.Concurrency
22+
import codingstandards.cpp.ConcurrencyNew
2323

2424
from AtomicCompareExchange ace
2525
where

0 commit comments

Comments
 (0)