Skip to content

Commit 23876cb

Browse files
committed
C++: Only allow taint to a FieldAddressInstruction if it's a union type.
1 parent eb4f1e1 commit 23876cb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private predicate operandToInstructionTaintStep(Operand opFrom, Instruction inst
6464
or
6565
instrTo instanceof PointerArithmeticInstruction
6666
or
67-
instrTo instanceof FieldAddressInstruction
67+
instrTo.(FieldAddressInstruction).getField().getDeclaringType() instanceof Union
6868
or
6969
// The `CopyInstruction` case is also present in non-taint data flow, but
7070
// that uses `getDef` rather than `getAnyDef`. For taint, we want flow

cpp/ql/test/library-tests/dataflow/taint-tests/map.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ void test_map()
152152
for (i2 = m2.begin(); i2 != m2.end(); i2++)
153153
{
154154
sink(*i2); // $ ast,ir
155-
sink(i2->first); // $ SPURIOUS: ir
156-
sink(i2->second); // $ ir MISSING: ast
155+
sink(i2->first); // clean
156+
sink(i2->second); // $ MISSING: ast,ir
157157
}
158158
for (i3 = m3.begin(); i3 != m3.end(); i3++)
159159
{
@@ -304,8 +304,8 @@ void test_unordered_map()
304304
for (i2 = m2.begin(); i2 != m2.end(); i2++)
305305
{
306306
sink(*i2); // $ ast,ir
307-
sink(i2->first); // $ SPURIOUS: ir
308-
sink(i2->second); // $ ir MISSING: ast
307+
sink(i2->first); // clean
308+
sink(i2->second); // $ MISSING: ast,ir
309309
}
310310
for (i3 = m3.begin(); i3 != m3.end(); i3++)
311311
{

0 commit comments

Comments
 (0)