Skip to content

Commit 535a69c

Browse files
committed
Merge branch 'main' into logfix
2 parents 7e962dc + e109892 commit 535a69c

File tree

269 files changed

+4930
-2103
lines changed

Some content is hidden

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

269 files changed

+4930
-2103
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll

Lines changed: 190 additions & 104 deletions
Large diffs are not rendered by default.

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedElement.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,9 @@ abstract class TranslatedElement extends TTranslatedElement {
824824
/** DEPRECATED: Alias for getAst */
825825
deprecated Locatable getAST() { result = this.getAst() }
826826

827+
/** Gets the location of this element. */
828+
Location getLocation() { result = this.getAst().getLocation() }
829+
827830
/**
828831
* Get the first instruction to be executed in the evaluation of this element.
829832
*/

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1956,9 +1956,7 @@ class TranslatedNonConstantAllocationSize extends TranslatedAllocationSize {
19561956
result = this.getExtent().getResult()
19571957
}
19581958

1959-
private TranslatedExpr getExtent() {
1960-
result = getTranslatedExpr(expr.getExtent().getFullyConverted())
1961-
}
1959+
TranslatedExpr getExtent() { result = getTranslatedExpr(expr.getExtent().getFullyConverted()) }
19621960
}
19631961

19641962
/**

cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedGlobalVar.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ class TranslatedStaticStorageDurationVarInit extends TranslatedRootElement,
2222

2323
final override Declaration getFunction() { result = var }
2424

25-
final Location getLocation() { result = var.getLocation() }
26-
2725
override Instruction getFirstInstruction() { result = this.getInstruction(EnterFunctionTag()) }
2826

2927
override TranslatedElement getChild(int n) {

cpp/ql/lib/semmle/code/cpp/security/InvalidPointerDereference/AllocationToInvalidPointer.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ predicate hasSize(HeuristicAllocationExpr alloc, DataFlow::Node n, int state) {
7272
// Compute `delta` as the constant difference between `x` and `x + 1`.
7373
bounded1(any(Instruction instr | instr.getUnconvertedResultExpression() = size),
7474
any(LoadInstruction load | load.getUnconvertedResultExpression() = va), delta) and
75-
n.asConvertedExpr() = va.getFullyConverted() and
75+
n.asExpr() = va and
7676
state = delta
7777
)
7878
}
@@ -210,7 +210,7 @@ private module InterestingPointerAddInstruction {
210210
predicate isSource(DataFlow::Node source) {
211211
// The sources is the same as in the sources for the second
212212
// projection in the `AllocToInvalidPointerConfig` module.
213-
hasSize(source.asConvertedExpr(), _, _)
213+
hasSize(source.asExpr(), _, _)
214214
}
215215

216216
int fieldFlowBranchLimit() { result = allocationToInvalidPointerFieldFlowBranchLimit() }
@@ -243,7 +243,7 @@ private module InterestingPointerAddInstruction {
243243
*/
244244
predicate isInterestingSize(DataFlow::Node n) {
245245
exists(DataFlow::Node alloc |
246-
hasSize(alloc.asConvertedExpr(), n, _) and
246+
hasSize(alloc.asExpr(), n, _) and
247247
flow(alloc, _)
248248
)
249249
}
@@ -268,7 +268,7 @@ private module Config implements ProductFlow::StateConfigSig {
268268
// we use `state2` to remember that there was an offset (in this case an offset of `1`) added
269269
// to the size of the allocation. This state is then checked in `isSinkPair`.
270270
exists(unit) and
271-
hasSize(allocSource.asConvertedExpr(), sizeSource, sizeAddend)
271+
hasSize(allocSource.asExpr(), sizeSource, sizeAddend)
272272
}
273273

274274
int fieldFlowBranchLimit1() { result = allocationToInvalidPointerFieldFlowBranchLimit() }

cpp/ql/src/Critical/FlowAfterFree.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ module FlowFromFree<isSinkSig/2 isASink, isExcludedSig/2 isExcluded> {
9898
* is being freed by a deallocation expression `dealloc`.
9999
*/
100100
predicate isFree(DataFlow::Node n, Expr e, DeallocationExpr dealloc) {
101-
e = dealloc.getFreedExpr() and
102-
e = n.asExpr() and
101+
exists(Expr conv |
102+
e = conv.getUnconverted() and
103+
conv = dealloc.getFreedExpr().getFullyConverted() and
104+
conv = n.asConvertedExpr()
105+
) and
103106
// Ignore realloc functions
104107
not exists(dealloc.(FunctionCall).getTarget().(AllocationFunction).getReallocPtrArg())
105108
}

cpp/ql/src/Likely Bugs/Leap Year/LeapYear.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ deprecated class PossibleYearArithmeticOperationCheckConfiguration extends Taint
296296
}
297297

298298
override predicate isSource(DataFlow::Node source) {
299-
exists(Operation op | op = source.asConvertedExpr() |
299+
exists(Operation op | op = source.asExpr() |
300300
op.getAChild*().getValue().toInt() = 365 and
301301
(
302302
not op.getParent() instanceof Expr or
@@ -321,7 +321,7 @@ deprecated class PossibleYearArithmeticOperationCheckConfiguration extends Taint
321321

322322
override predicate isSink(DataFlow::Node sink) {
323323
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr |
324-
aexpr.getRValue() = sink.asConvertedExpr()
324+
aexpr.getRValue() = sink.asExpr()
325325
|
326326
(dds instanceof PackedTimeType or dds instanceof UnpackedTimeType) and
327327
fa.getQualifier().getUnderlyingType() = dds and
@@ -336,7 +336,7 @@ deprecated class PossibleYearArithmeticOperationCheckConfiguration extends Taint
336336
*/
337337
private module PossibleYearArithmeticOperationCheckConfig implements DataFlow::ConfigSig {
338338
predicate isSource(DataFlow::Node source) {
339-
exists(Operation op | op = source.asConvertedExpr() |
339+
exists(Operation op | op = source.asExpr() |
340340
op.getAChild*().getValue().toInt() = 365 and
341341
(
342342
not op.getParent() instanceof Expr or
@@ -361,7 +361,7 @@ private module PossibleYearArithmeticOperationCheckConfig implements DataFlow::C
361361

362362
predicate isSink(DataFlow::Node sink) {
363363
exists(StructLikeClass dds, FieldAccess fa, AssignExpr aexpr |
364-
aexpr.getRValue() = sink.asConvertedExpr()
364+
aexpr.getRValue() = sink.asExpr()
365365
|
366366
(dds instanceof PackedTimeType or dds instanceof UnpackedTimeType) and
367367
fa.getQualifier().getUnderlyingType() = dds and

cpp/ql/src/Security/CWE/CWE-089/SqlTainted.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Expr asSinkExpr(DataFlow::Node node) {
3030
result = node.asIndirectArgument()
3131
or
3232
// We want the conversion so we only get one node for the expression
33-
result = node.asConvertedExpr()
33+
result = node.asExpr()
3434
}
3535

3636
module SqlTaintedConfig implements DataFlow::ConfigSig {

cpp/ql/src/Security/CWE/CWE-119/OverrunWriteProductFlow.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ predicate hasSize(HeuristicAllocationExpr alloc, DataFlow::Node n, int state) {
3838
// Compute `delta` as the constant difference between `x` and `x + 1`.
3939
bounded(any(Instruction instr | instr.getUnconvertedResultExpression() = size),
4040
any(LoadInstruction load | load.getUnconvertedResultExpression() = va), delta) and
41-
n.asConvertedExpr() = va.getFullyConverted() and
41+
n.asExpr() = va and
4242
state = delta
4343
)
4444
}
@@ -213,7 +213,7 @@ module StringSizeConfig implements ProductFlow::StateConfigSig {
213213
// we use `state2` to remember that there was an offset (in this case an offset of `1`) added
214214
// to the size of the allocation. This state is then checked in `isSinkPair`.
215215
exists(state1) and
216-
hasSize(bufSource.asConvertedExpr(), sizeSource, state2) and
216+
hasSize(bufSource.asExpr(), sizeSource, state2) and
217217
validState(sizeSource, state2)
218218
}
219219

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import TaintedAllocationSize::PathGraph
2626
* taint sink.
2727
*/
2828
predicate allocSink(HeuristicAllocationExpr alloc, DataFlow::Node sink) {
29-
exists(Expr e | e = sink.asConvertedExpr() |
29+
exists(Expr e | e = sink.asExpr() |
3030
e = alloc.getAChild() and
3131
e.getUnspecifiedType() instanceof IntegralType
3232
)

0 commit comments

Comments
 (0)