Skip to content

Commit 0c924c2

Browse files
committed
C++: Taint-flow through integer to boolean casts.
1 parent e1c3266 commit 0c924c2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ private predicate operandToInstructionTaintStep(Operand opFrom, Instruction inst
7272
or
7373
instrTo.(FieldAddressInstruction).getField().getDeclaringType() instanceof Union
7474
)
75+
or
76+
// Taint from int to boolean casts. This ensures that we have flow to `!x` in:
77+
// ```cpp
78+
// x = integer_source();
79+
// if(!x) { ... }
80+
// ```
81+
exists(Operand zero |
82+
zero.getDef().(ConstantValueInstruction).getValue() = "0" and
83+
instrTo.(CompareNEInstruction).hasOperands(opFrom, zero)
84+
)
7585
}
7686

7787
/**

0 commit comments

Comments
 (0)