Parcourir la source

Properly type handles to prevent overflows

This change is needed for 32 bit targets as the default type is int32
and the handle constants do not fit into it.

Signed-off-by: Jiri Appl <jiria@microsoft.com>
Jiri Appl il y a 6 ans
Parent
commit
33a779e308
1 fichiers modifiés avec 3 ajouts et 3 suppressions
  1. 3 3
      cmd/dockerd/service_windows.go

+ 3 - 3
cmd/dockerd/service_windows.go

@@ -396,8 +396,8 @@ func initPanicFile(path string) error {
 	// Update STD_ERROR_HANDLE to point to the panic file so that Go writes to
 	// Update STD_ERROR_HANDLE to point to the panic file so that Go writes to
 	// it when it panics. Remember the old stderr to restore it before removing
 	// it when it panics. Remember the old stderr to restore it before removing
 	// the panic file.
 	// the panic file.
-	sh := windows.STD_ERROR_HANDLE
-	h, err := windows.GetStdHandle(uint32(sh))
+	sh := uint32(windows.STD_ERROR_HANDLE)
+	h, err := windows.GetStdHandle(sh)
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
@@ -421,7 +421,7 @@ func initPanicFile(path string) error {
 func removePanicFile() {
 func removePanicFile() {
 	if st, err := panicFile.Stat(); err == nil {
 	if st, err := panicFile.Stat(); err == nil {
 		if st.Size() == 0 {
 		if st.Size() == 0 {
-			sh := windows.STD_ERROR_HANDLE
+			sh := uint32(windows.STD_ERROR_HANDLE)
 			setStdHandle.Call(uintptr(sh), uintptr(oldStderr))
 			setStdHandle.Call(uintptr(sh), uintptr(oldStderr))
 			panicFile.Close()
 			panicFile.Close()
 			os.Remove(panicFile.Name())
 			os.Remove(panicFile.Name())