]> Cypherpunks repositories - gostls13.git/commit
internal/syscall/windows: change WSAMsg.Name type
authorAlex Brainman <alex.brainman@gmail.com>
Sat, 7 Mar 2020 00:08:06 +0000 (11:08 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Thu, 2 Apr 2020 09:00:44 +0000 (09:00 +0000)
commit801cd7c84d42dcf18256416524aa0d31d6305830
tree271c9cf4af3a2cd45341d44a0e18c2ccfe129e3d
parent9667294d8f5c8c6e2c48efa1ced98cb7e9cfaf51
internal/syscall/windows: change WSAMsg.Name type

The problem was discovered while running

go test -a -short -gcflags=all=-d=checkptr -run=TestUDPConnSpecificMethods net

WSAMsg is type defined by Windows. And WSAMsg.Name could point to two
different structures for IPv4 and IPV6 sockets.

Currently WSAMsg.Name is declared as *syscall.RawSockaddrAny. But that
violates

(1) Conversion of a *T1 to Pointer to *T2.

rule of

https://golang.org/pkg/unsafe/#Pointer

When we convert *syscall.RawSockaddrInet4 into *syscall.RawSockaddrAny,
syscall.RawSockaddrInet4 and syscall.RawSockaddrAny do not share an
equivalent memory layout.

Same for *syscall.SockaddrInet6 into *syscall.RawSockaddrAny.

This CL changes WSAMsg.Name type to *syscall.Pointer. syscall.Pointer
length is 0, and that at least makes type checker happy.

After this change I was able to run

go test -a -short -gcflags=all=-d=checkptr std cmd

without type checker complaining.

Updates #34972

Change-Id: Ic5c2321c20abd805c687ee16ef6f643a2f8cd93f
Reviewed-on: https://go-review.googlesource.com/c/go/+/222457
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/internal/poll/fd_windows.go
src/internal/syscall/windows/syscall_windows.go