From: Alex Brainman Date: Mon, 29 Jun 2015 01:19:33 +0000 (+1000) Subject: syscall: return error instead of panicking in windows StartProcess X-Git-Tag: go1.5beta1~70 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0bafe0e5b284d41052be418052f61ab03504d7f7;p=gostls13.git syscall: return error instead of panicking in windows StartProcess Fixes #11417 Change-Id: Iacea829a48b39df0a4f751b06b19e918fbb713d0 Reviewed-on: https://go-review.googlesource.com/11604 Reviewed-by: Rob Pike --- diff --git a/src/os/os_windows_test.go b/src/os/os_windows_test.go index 3ea0fc7f4f..ee19b2b33a 100644 --- a/src/os/os_windows_test.go +++ b/src/os/os_windows_test.go @@ -117,3 +117,12 @@ func TestStatJunctionLink(t *testing.T) { t.Fatalf("link should point to %v but points to %v instead", expected, got) } } + +func TestStartProcessAttr(t *testing.T) { + p, err := os.StartProcess(os.Getenv("COMSPEC"), []string{"/c", "cd"}, new(os.ProcAttr)) + if err != nil { + return + } + defer p.Wait() + t.Fatalf("StartProcess expected to fail, but succeeded.") +} diff --git a/src/syscall/exec_windows.go b/src/syscall/exec_windows.go index cc1abc4d03..5a01843d2b 100644 --- a/src/syscall/exec_windows.go +++ b/src/syscall/exec_windows.go @@ -244,6 +244,9 @@ func StartProcess(argv0 string, argv []string, attr *ProcAttr) (pid int, handle if len(attr.Files) > 3 { return 0, 0, EWINDOWS } + if len(attr.Files) < 3 { + return 0, 0, EINVAL + } if len(attr.Dir) != 0 { // StartProcess assumes that argv0 is relative to attr.Dir,