Skip to content

Commit 9fb94d8

Browse files
committed
C++: performance tweaks for InsufficientKeySize
1 parent a60fe9f commit 9fb94d8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cpp/ql/src/Security/CWE/CWE-326/InsufficientKeySize.ql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ class KeyStrengthFlow extends DataFlow::Configuration {
3131
KeyStrengthFlow() { this = "KeyStrengthFlow" }
3232

3333
override predicate isSource(DataFlow::Node node) {
34-
node.asInstruction().(IntegerConstantInstruction).getValue() != "0"
34+
exists(int bits |
35+
node.asInstruction().(IntegerConstantInstruction).getValue().toInt() = bits and
36+
bits < getMinimumKeyStrength(_, _) and
37+
bits > 0 // exclude sentinel values
3538
}
3639

3740
override predicate isSink(DataFlow::Node node) {

0 commit comments

Comments
 (0)