]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: return error instead of panicking in windows StartProcess
authorAlex Brainman <alex.brainman@gmail.com>
Mon, 29 Jun 2015 01:19:33 +0000 (11:19 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Mon, 29 Jun 2015 03:54:33 +0000 (03:54 +0000)
Fixes #11417

Change-Id: Iacea829a48b39df0a4f751b06b19e918fbb713d0
Reviewed-on: https://go-review.googlesource.com/11604
Reviewed-by: Rob Pike <r@golang.org>
src/os/os_windows_test.go
src/syscall/exec_windows.go

index 3ea0fc7f4f29f3f7728f1db2b7d0850e362b638c..ee19b2b33a63b1c05627fbf8025ddc6b686f4217 100644 (file)
@@ -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.")
+}
index cc1abc4d0354359d423b4e2c9dbbf8c82c365fc4..5a01843d2bef08e6cb35dc71918a2c21e8255c3c 100644 (file)
@@ -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,