mirror of
https://github.com/golang/go
synced 2024-11-18 08:54:45 -07:00
syscall: fix windows WSASendto -d=checkptr violation
WSASendto converts unsafe.Pointer to *syscall.RawSockaddrAny. But that violates every rule of https://golang.org/pkg/unsafe/#Pointer Implement WSASendto by calling Windows WSASendTo API by calling syscall.Syscall9 directly. This allows us to comply with (4) Conversion of a Pointer to a uintptr when calling syscall.Syscall rule. After this change, this commands succeeds: go test -a -short -gcflags=all=-d=checkptr -run=TestPacketConn net Updates #34972 Change-Id: Ib9a810bedf9e05251b7d3c7f69e15bfbd177ac62 Reviewed-on: https://go-review.googlesource.com/c/go/+/220544 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
95773ab9b0
commit
9667294d8f
@ -871,11 +871,19 @@ func Shutdown(fd Handle, how int) (err error) {
|
||||
}
|
||||
|
||||
func WSASendto(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to Sockaddr, overlapped *Overlapped, croutine *byte) (err error) {
|
||||
rsa, l, err := to.sockaddr()
|
||||
rsa, len, err := to.sockaddr()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return WSASendTo(s, bufs, bufcnt, sent, flags, (*RawSockaddrAny)(unsafe.Pointer(rsa)), l, overlapped, croutine)
|
||||
r1, _, e1 := Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(rsa)), uintptr(len), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
|
||||
if r1 == socket_error {
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
} else {
|
||||
err = EINVAL
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func LoadGetAddrInfo() error {
|
||||
|
Loading…
Reference in New Issue
Block a user