From 33241d7298e0c621cfc4cc9f878dba9eff2b1c3d Mon Sep 17 00:00:00 2001 From: Neal Patel Date: Sat, 11 Apr 2026 12:00:52 -0400 Subject: os/exec: use argv() to avoid panic inside of Cmd.String() A surprisingly non-zero amount of direct uses Cmd make this panic possible. Change-Id: If86cabfb0f7c0250e2a5aa3fcaba367de5d10ca4 Reviewed-on: https://go-review.googlesource.com/c/go/+/765680 Reviewed-by: Ian Lance Taylor Auto-Submit: Neal Patel TryBot-Bypass: Nicholas Husin Reviewed-by: Carlos Amedee Reviewed-by: Nicholas Husin Reviewed-by: Keith Randall --- src/os/exec/exec.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/os/exec/exec.go') diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index 26ddfe633c..24cd6b141a 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -516,7 +516,7 @@ func (c *Cmd) String() string { // report the exact executable path (plus args) b := new(strings.Builder) b.WriteString(c.Path) - for _, a := range c.Args[1:] { + for _, a := range c.argv()[1:] { b.WriteByte(' ') b.WriteString(a) } -- cgit v1.3