Skip to content

Commit

Permalink
syscall: don't check non-existent return code in GetStartupInfo
Browse files Browse the repository at this point in the history
Fixes golang#31316

Change-Id: I1ca5968836e7bcad91496e4ed3cf1a0caf1375f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/520275
Run-TryBot: Tobias Klauser <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Auto-Submit: Tobias Klauser <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
  • Loading branch information
tklauser authored and gopherbot committed Aug 17, 2023
1 parent 6c431fa commit 51fd0cb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/syscall/syscall_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func NewCallbackCDecl(fn any) uintptr {
//sys OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error)
//sys TerminateProcess(handle Handle, exitcode uint32) (err error)
//sys GetExitCodeProcess(handle Handle, exitcode *uint32) (err error)
//sys GetStartupInfo(startupInfo *StartupInfo) (err error) = GetStartupInfoW
//sys getStartupInfo(startupInfo *StartupInfo) = GetStartupInfoW
//sys GetCurrentProcess() (pseudoHandle Handle, err error)
//sys GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error)
//sys DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error)
Expand Down Expand Up @@ -1437,3 +1437,8 @@ func newProcThreadAttributeList(maxAttrCount uint32) (*_PROC_THREAD_ATTRIBUTE_LI
func RegEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
return regEnumKeyEx(key, index, name, nameLen, reserved, class, classLen, lastWriteTime)
}

func GetStartupInfo(startupInfo *StartupInfo) error {
getStartupInfo(startupInfo)
return nil
}
9 changes: 9 additions & 0 deletions src/syscall/syscall_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ func TestGetwd_DoesNotPanicWhenPathIsLong(t *testing.T) {
syscall.Getwd()
}

func TestGetStartupInfo(t *testing.T) {
var si syscall.StartupInfo
err := syscall.GetStartupInfo(&si)
if err != nil {
// see https://go.dev/issue/31316
t.Fatalf("GetStartupInfo: got error %v, want nil", err)
}
}

func FuzzUTF16FromString(f *testing.F) {
f.Add("hi") // ASCII
f.Add("â") // latin1
Expand Down
7 changes: 2 additions & 5 deletions src/syscall/zsyscall_windows.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 51fd0cb

Please sign in to comment.