Skip to content

Commit 6884edf

Browse files
authored
Merge branch 'main' into atorralba/promote-unsafe-android-webview-fetch
2 parents 1f1a1bd + 10e76ff commit 6884edf

File tree

70 files changed

+2484
-211
lines changed

Some content is hidden

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

70 files changed

+2484
-211
lines changed

cpp/ql/src/Likely Bugs/Arithmetic/SignedOverflowCheck.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* @id cpp/signed-overflow-check
1010
* @tags correctness
1111
* security
12+
* external/cwe/cwe-128
13+
* external/cwe/cwe-190
1214
*/
1315

1416
import cpp

cpp/ql/src/Likely Bugs/Conversion/CastArrayPointerArithmetic.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
* @kind path-problem
88
* @problem.severity warning
99
* @precision high
10+
* @id cpp/upcast-array-pointer-arithmetic
1011
* @tags correctness
1112
* reliability
1213
* security
1314
* external/cwe/cwe-119
1415
* external/cwe/cwe-843
15-
* @id cpp/upcast-array-pointer-arithmetic
1616
*/
1717

1818
import cpp

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @tags reliability
99
* correctness
1010
* security
11+
* external/cwe/cwe-190
12+
* external/cwe/cwe-253
1113
*/
1214

1315
import cpp

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @tags reliability
1010
* correctness
1111
* security
12+
* external/cwe/cwe-234
1213
* external/cwe/cwe-685
1314
*/
1415

cpp/ql/src/Likely Bugs/Memory Management/PointerOverflow.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @id cpp/pointer-overflow-check
99
* @tags reliability
1010
* security
11+
* external/cwe/cwe-758
1112
*/
1213

1314
import cpp

cpp/ql/src/Likely Bugs/OO/UnsafeUseOfThis.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* @tags correctness
1111
* language-features
1212
* security
13+
* external/cwe/cwe-670
1314
*/
1415

1516
import cpp

cpp/ql/src/Likely Bugs/Underspecified Functions/TooFewArguments.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* @tags correctness
1313
* maintainability
1414
* security
15+
* external/cwe/cwe-234
16+
* external/cwe/cwe-685
1517
*/
1618

1719
import cpp

cpp/ql/src/experimental/Security/CWE/CWE-570/WrongInDetectingAndHandlingMemoryAllocationErrors.ql

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,27 @@ class WrongCheckErrorOperatorNew extends FunctionCall {
5353
* Holds if results call `operator new` check in `operator if`.
5454
*/
5555
predicate isExistsIfCondition() {
56-
exists(IfCompareWithZero ifc, AssignExpr aex, Initializer it |
56+
exists(IfCompareWithZero ifc |
5757
// call `operator new` directly from the condition of `operator if`.
5858
this = ifc.getCondition().getAChild*()
5959
or
60-
// check results call `operator new` with variable appropriation
6160
postDominates(ifc, this) and
62-
aex.getAChild() = exp and
63-
ifc.getCondition().getAChild().(VariableAccess).getTarget() =
64-
aex.getLValue().(VariableAccess).getTarget()
65-
or
66-
// check results call `operator new` with declaration variable
67-
postDominates(ifc, this) and
68-
exp = it.getExpr() and
69-
it.getDeclaration() = ifc.getCondition().getAChild().(VariableAccess).getTarget()
61+
exists(Variable v |
62+
v = ifc.getCondition().getAChild().(VariableAccess).getTarget() and
63+
(
64+
exists(AssignExpr aex |
65+
// check results call `operator new` with variable appropriation
66+
aex.getAChild() = exp and
67+
v = aex.getLValue().(VariableAccess).getTarget()
68+
)
69+
or
70+
exists(Initializer it |
71+
// check results call `operator new` with declaration variable
72+
exp = it.getExpr() and
73+
it.getDeclaration() = v
74+
)
75+
)
76+
)
7077
)
7178
}
7279

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,8 @@ class Instruction extends Construction::TStageInstruction {
297297
/**
298298
* Gets the opcode that specifies the operation performed by this instruction.
299299
*/
300-
final Opcode getOpcode() { result = Construction::getInstructionOpcode(this) }
300+
pragma[inline]
301+
final Opcode getOpcode() { Construction::getInstructionOpcode(result, this) }
301302

302303
/**
303304
* Gets all direct uses of the result of this instruction. The result can be

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/internal/SSAConstruction.qll

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,15 +338,21 @@ private module Cached {
338338
instr = unreachedInstruction(_) and result = Language::getVoidType()
339339
}
340340

341+
/**
342+
* Holds if `opcode` is the opcode that specifies the operation performed by `instr`.
343+
*
344+
* The parameters are ordered such that they produce a clean join (with no need for reordering)
345+
* in the characteristic predicates of the `Instruction` subclasses.
346+
*/
341347
cached
342-
Opcode getInstructionOpcode(Instruction instr) {
343-
result = getOldInstruction(instr).getOpcode()
348+
predicate getInstructionOpcode(Opcode opcode, Instruction instr) {
349+
opcode = getOldInstruction(instr).getOpcode()
344350
or
345-
instr = phiInstruction(_, _) and result instanceof Opcode::Phi
351+
instr = phiInstruction(_, _) and opcode instanceof Opcode::Phi
346352
or
347-
instr = chiInstruction(_) and result instanceof Opcode::Chi
353+
instr = chiInstruction(_) and opcode instanceof Opcode::Chi
348354
or
349-
instr = unreachedInstruction(_) and result instanceof Opcode::Unreached
355+
instr = unreachedInstruction(_) and opcode instanceof Opcode::Unreached
350356
}
351357

352358
cached

0 commit comments

Comments
 (0)