Skip to content

Commit a81989d

Browse files
committed
C++: Simplify the 'SSLResultNotChecked' query.
1 parent 9f47996 commit a81989d

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

cpp/ql/src/Security/CWE/CWE-295/SSLResultNotChecked.ql

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,9 @@ predicate resultIsChecked(SslGetPeerCertificateCall getCertCall, ControlFlowNode
5555
predicate certIsZero(
5656
SslGetPeerCertificateCall getCertCall, ControlFlowNode node1, ControlFlowNode node2
5757
) {
58-
exists(Expr cert | cert = globalValueNumber(getCertCall).getAnExpr() |
59-
exists(GuardCondition guard, Expr zero |
60-
zero.getValue().toInt() = 0 and
61-
node1 = guard and
62-
(
63-
// if (cert == zero) {
64-
guard.comparesEq(cert, zero, 0, true, true) and
65-
node2 = guard.getATrueSuccessor()
66-
or
67-
// if (cert != zero) { }
68-
guard.comparesEq(cert, zero, 0, false, true) and
69-
node2 = guard.getAFalseSuccessor()
70-
)
71-
)
72-
or
73-
(
74-
// if (cert) { }
75-
node1 = cert
76-
or
77-
// if (!cert) {
78-
node1.(NotExpr).getAChild() = cert
79-
) and
80-
node2 = node1.getASuccessor() and
81-
not cert.(GuardCondition).controls(node2, true) // cert may be false
58+
exists(Expr cert |
59+
cert = globalValueNumber(getCertCall).getAnExpr() and
60+
node1.(GuardCondition).ensuresEqEdge(cert, 0, _, node2.getBasicBlock(), true)
8261
)
8362
}
8463

0 commit comments

Comments
 (0)