Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/sys/windows: RawSockaddr uses a signed int array for the Data field #41240

Closed
ArtificialAmateur opened this issue Sep 6, 2020 · 1 comment

Comments

@ArtificialAmateur
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.15 windows/amd64

Does this issue reproduce with the latest release?

It should as it's still written as is here.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Artificial Amateur\AppData\Local\go-build
set GOENV=C:\Users\Artificial Amateur\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Artificial Amateur\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Artificial Amateur\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=Z:\go-netstat\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\ARTIFI~1\AppData\Local\Temp\go-b
uild667920362=/tmp/go-build -gno-record-gcc-switches

What did you do?

Ran windows syscall of GetAdaptersAddresses and printed the value of IpAdapterAddresses.FirstUnicastAddress.Address.Sockaddr.Addr.Data

What did you expect to see?

[0 0 172 16 19 129 0 0 0 0 0 0 0 0]

What did you see instead?

[0 0 -84 16 19 -127 0 0 0 0 0 0 0 0]

This is a minor issue with a simple change of making the Data field of type uint8 or byte.

@gopherbot gopherbot added this to the Unreleased milestone Sep 6, 2020
@ArtificialAmateur ArtificialAmateur changed the title x/sys: RawSockaddr uses a signed int array for the Data field x/sys/windows: RawSockaddr uses a signed int array for the Data field Sep 6, 2020
@ArtificialAmateur
Copy link
Author

WinAPI uses a char https://docs.microsoft.com/en-us/windows/win32/winsock/sockaddr-2

I dont agree with it when the other address structs (in_addr) use bytes, but it's the golang code matches.

@golang golang locked and limited conversation to collaborators Sep 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants