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: ParseHeader will yield incorrect values on certain OSes #53228

Closed
pitust opened this issue Jun 3, 2022 · 1 comment
Closed

x/net/ipv4: ParseHeader will yield incorrect values on certain OSes #53228

pitust opened this issue Jun 3, 2022 · 1 comment

Comments

@pitust
Copy link

pitust commented Jun 3, 2022

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

$ go version
go version go1.18.3 darwin/arm64

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
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/pitust/Library/Caches/go-build"
GOENV="/Users/pitust/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/pitust/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/pitust/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.17.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.17.5/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/pitust/code/netroute2/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4y/_38brkys0wjgsnl5nfqnp13h0000gp/T/go-build860342338=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I am attempting to parse IPv4 packets with ipv4.ParseHeader. I get the network packets from a utun device, which meets the requirement for ipv4.ParseHeader:

The provided b must be in the format used by a raw IP socket on the local system.
However, two fields: TotalLen and FragOff are parsed incorrectly.

What did you expect to see?

The TotalLen field being less than the size of the packet that was received.

What did you see instead?

The TotalLen field was bigger than the (a) MTU (b) the size of the packet buffer (c) the packet that was read from the device, as the values have not been read in big endian.

@dmitshur dmitshur changed the title golang.org/x/net: ipv4.ParseHeader will yield incorrect values on certain OSes x/net/ipv4: ParseHeader will yield incorrect values on certain OSes Jun 3, 2022
@gopherbot gopherbot added this to the Unreleased milestone Jun 3, 2022
@seankhliao
Copy link
Member

Duplicate of #32118

@seankhliao seankhliao marked this as a duplicate of #32118 Jun 3, 2022
@golang golang locked and limited conversation to collaborators Jun 3, 2023
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