Skip to content

Commit ec7cbf9

Browse files
committed
Add failing test for flow out of varargs parameter
1 parent 1935c26 commit ec7cbf9

File tree

1 file changed

+11
-1
lines changed
  • go/ql/test/library-tests/semmle/go/dataflow/VarArgs

1 file changed

+11
-1
lines changed

go/ql/test/library-tests/semmle/go/dataflow/VarArgs/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ func source() string {
44
return "untrusted data"
55
}
66

7-
func sink(string) {
7+
func sink(any) {
88
}
99

1010
type A struct {
@@ -19,6 +19,10 @@ func functionWithVarArgsParameter(s ...string) string {
1919
return s[1]
2020
}
2121

22+
func functionWithVarArgsOutParameter(in string, out ...*string) {
23+
*out[0] = in
24+
}
25+
2226
func functionWithSliceOfStructsParameter(s []A) string {
2327
return s[1].f
2428
}
@@ -38,6 +42,12 @@ func main() {
3842
sink(functionWithVarArgsParameter(sSlice...)) // $ hasValueFlow="call to functionWithVarArgsParameter"
3943
sink(functionWithVarArgsParameter(s0, s1)) // $ hasValueFlow="call to functionWithVarArgsParameter"
4044

45+
var out1 *string
46+
var out2 *string
47+
functionWithVarArgsOutParameter(source(), out1, out2)
48+
sink(out1) // $ MISSING: hasValueFlow="out1"
49+
sink(out2) // $ MISSING: hasValueFlow="out2"
50+
4151
sliceOfStructs := []A{{f: source()}}
4252
sink(sliceOfStructs[0].f) // $ hasValueFlow="selection of f"
4353

0 commit comments

Comments
 (0)