Skip to content

Commit e121a13

Browse files
owen-mcCopilot
andcommitted
Go: Fix read-only dereference backflow test
Previously, `calleeReadsOnly` assigned `p = &inner{val: source()}`, which stored taint inside `[PointerContent, FieldContent(val)]` rather than tainting `p` with an empty access path. Before removing `PostUpdateNode`s on read-only pointer dereferences, `_ = p.val` generated `p [postupdate]` and spurious backflow to the caller happened via `referenceStep` (`implicit-deref p -> p [postupdate]`), an additional taint step that only fires when `implicit-deref p` has an empty access path. As a result, `testNoBackflowFromReadOnlyDeref` passed even without the fix. Assign `p = taint()` from a pointer-returning source instead so `p` itself is tainted and the test fails without the fix. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c52d8c6 commit e121a13

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes

‎go/ql/test/library-tests/semmle/go/dataflow/PostUpdateNodes/flows.go‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,13 @@ func testAddressOfFieldUnmarshal() {
7979
sink(o.Inner.Val) // $ hasTaintFlow="selection of Val"
8080
}
8181

82+
func taint() *inner {
83+
return &inner{}
84+
}
85+
8286
func calleeReadsOnly(p *inner) {
8387
if p == nil {
84-
p = &inner{val: source()}
88+
p = taint()
8589
}
8690
_ = p.val
8791
}

0 commit comments

Comments
 (0)