Skip to content

Commit 9f86bcb

Browse files
committed
Swift: Proof of concept fix.
1 parent 15227d3 commit 9f86bcb

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ private predicate modifiable(Argument arg) {
211211
arg.getExpr() instanceof InOutExpr
212212
or
213213
arg.getExpr().getType() instanceof NominalType
214+
or
215+
arg.getLabel() = "ptr"
214216
}
215217

216218
predicate modifiableParam(ParamDecl param) {

swift/ql/test/library-tests/dataflow/taint/libraries/unsafepointer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func taintPointer(ptr: UnsafeMutablePointer<String>) {
2525
}
2626

2727
func clearPointer2(ptr: UnsafeMutablePointer<String>) {
28-
sink(arg: ptr.pointee) // $ MISSING: tainted=21
28+
sink(arg: ptr.pointee) // $ tainted=21
2929
sink(arg: ptr)
3030

3131
ptr.pointee = "abc"
@@ -42,12 +42,12 @@ func testMutatingPointerInCall(ptr: UnsafeMutablePointer<String>) {
4242

4343
taintPointer(ptr: ptr) // mutates `ptr` pointee with a tainted value
4444

45-
sink(arg: ptr.pointee) // $ MISSING: tainted=21
45+
sink(arg: ptr.pointee) // $ tainted=21
4646
sink(arg: ptr)
4747

4848
clearPointer2(ptr: ptr)
4949

50-
sink(arg: ptr.pointee)
50+
sink(arg: ptr.pointee) // $ SPURIOUS: tainted=21
5151
sink(arg: ptr)
5252
}
5353

@@ -96,6 +96,6 @@ func testMutatingMyPointerInCall(ptr: MyPointer) {
9696

9797
taintMyPointer(ptr: ptr) // mutates `ptr` pointee with a tainted value
9898

99-
sink(arg: ptr.pointee) // $ MISSING: tainted=87
99+
sink(arg: ptr.pointee) // $ tainted=87
100100
sink(arg: ptr)
101101
}

0 commit comments

Comments
 (0)