Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1656540

Browse files
committed
C++: Reduce path duplication.
1 parent 2b37ebd commit 1656540

4 files changed

Lines changed: 355 additions & 448 deletions

File tree

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,15 +752,26 @@ private predicate exprNodeShouldBeIndirectOperand(IndirectOperand node, Expr e,
752752
not convertedExprMustBeOperand(e)
753753
}
754754

755+
private predicate indirectExprNodeShouldBeIndirectOperand0(
756+
VariableAddressInstruction instr, IndirectOperand node, Expr e
757+
) {
758+
instr = node.getOperand().getDef() and
759+
not node instanceof ExprNode and
760+
e = instr.getAst().(Expr).getUnconverted()
761+
}
762+
755763
/** Holds if `node` should be an `IndirectOperand` that maps `node.asIndirectExpr()` to `e`. */
756764
private predicate indirectExprNodeShouldBeIndirectOperand(IndirectOperand node, Expr e) {
757765
exists(Instruction instr |
758766
instr = node.getOperand().getDef() and
759767
not node instanceof ExprNode
760768
|
761-
e = instr.(VariableAddressInstruction).getAst().(Expr).getFullyConverted()
769+
exists(Expr e0 |
770+
indirectExprNodeShouldBeIndirectOperand0(instr, node, e0) and
771+
e = e0.getFullyConverted()
772+
)
762773
or
763-
not instr instanceof VariableAddressInstruction and
774+
not indirectExprNodeShouldBeIndirectOperand0(_, _, e.getUnconverted()) and
764775
e = instr.getConvertedResultExpression()
765776
)
766777
}

cpp/ql/src/Security/CWE/CWE-311/CleartextTransmission.ql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,7 @@ class ToEncryptionConfiguration extends TaintTracking2::Configuration {
261261
ToEncryptionConfiguration() { this = "ToEncryptionConfiguration" }
262262

263263
override predicate isSource(DataFlow::Node source) {
264-
any(FromSensitiveConfiguration config).hasFlow(source, _) and
265-
isSourceImpl(source)
264+
any(FromSensitiveConfiguration config).hasFlow(source, _)
266265
}
267266

268267
override predicate isSink(DataFlow::Node sink) { isSinkEncrypt(sink, _) }

0 commit comments

Comments
 (0)