Skip to content

Commit 29c9348

Browse files
committed
C++: DefaultTaintTracking flow from a to a[i]
Switching `security.TaintTracking` to use `DefaultTaintTracking` causes us to lose a result from `UnboundedWrite.ql`, while this commit restores it: diff --git a/semmlecode-cpp-tests/DO_NOT_DISTRIBUTE/security-tests/CWE-120/CERT/STR35-C/UnboundedWrite.expected b/semmlecode-cpp-tests/DO_NOT_DISTRIBUTE/security-tests/CWE-120/CERT/STR35-C/UnboundedWrite.expected index 1eba0e52f0e..d947b33b9d9 100644 --- a/semmlecode-cpp-tests/DO_NOT_DISTRIBUTE/security-tests/CWE-120/CERT/STR35-C/UnboundedWrite.expected +++ b/semmlecode-cpp-tests/DO_NOT_DISTRIBUTE/security-tests/CWE-120/CERT/STR35-C/UnboundedWrite.expected @@ -1,2 +1,3 @@ +| main.c:54:7:54:12 | call to strcat | This 'call to strcat' with input from $@ may overflow the destination. | main.c:93:15:93:18 | argv | argv | | main.c:99:9:99:12 | call to gets | This 'call to gets' with input from $@ may overflow the destination. | main.c:99:9:99:12 | call to gets | call to gets | | main.c:213:17:213:19 | buf | This 'scanf string argument' with input from $@ may overflow the destination. | main.c:213:17:213:19 | buf | buf |
1 parent 6f2e485 commit 29c9348

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) {
9090
predictableInstruction(i2.getAnOperand().getDef()) and
9191
i1 = i2.getAnOperand().getDef()
9292
)
93-
// TODO: Check that we have flow from `a` to `a[i]`. It may work for constant
94-
// `i` because there is flow through `predictable` `BinaryInstruction` and
95-
// through `LoadInstruction`.
96-
//
93+
or
94+
// This is part of the translation of `a[i]`, where we want taint to flow
95+
// from `a`.
96+
i2.(PointerAddInstruction).getLeft() = i1
9797
// TODO: Flow from argument to return of known functions: Port missing parts
9898
// of `returnArgument` to the `interfaces.Taint` and `interfaces.DataFlow`
9999
// libraries.

0 commit comments

Comments
 (0)