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/net: ipv4 header total length on GOOS darwin is incorrectly marshaled #37398

Closed
pete911 opened this issue Feb 24, 2020 · 2 comments
Closed

Comments

@pete911
Copy link

pete911 commented Feb 24, 2020

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

go version go1.13.8 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.8/libexec"
GOSUMDB="sum.golang.org"
GOTOOLDIR="/usr/local/Cellar/go/1.13.8/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

Set the ipv4 header total length field

// ...

iph := &ipv4.Header{
	Version:  ipv4.Version,
	Len:      ipv4.HeaderLen,
	TOS:      0,
	TotalLen: ipv4.HeaderLen + len(msg),
	TTL:      64,
	Protocol: protocol,
	Dst:      dst,
	Src:      src,
}

ip, _ := iph.Marshal()

// ... packet has incorrectly set total length - ip[2:4] bytes are reversed

What did you expect to see?

for example if packet total length is 37 I expect to see [0 37] set on byte index 2 and 3 (ip[2:4])

What did you see instead?

for example if packet total length is 37 I see [37 0] set on byte index 2 and 3 (ip[2:4])

@pete911 pete911 changed the title x/net: ipv4 header total length on GOOOS darwin is incorrectly marshaled x/net: ipv4 header total length on GOOS darwin is incorrectly marshaled Feb 24, 2020
@gopherbot gopherbot added this to the Unreleased milestone Feb 24, 2020
@vovapi
Copy link
Contributor

vovapi commented Feb 29, 2020

I think this duplicates #32118

@pete911
Copy link
Author

pete911 commented Feb 29, 2020

thanks @vovapi , it is indeed duplicate. closing this issues.

@pete911 pete911 closed this as completed Feb 29, 2020
@golang golang locked and limited conversation to collaborators Feb 28, 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

3 participants