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

cmd/go/internal/fsys: panic: runtime error: slice bounds out of range [3:2] #53475

Closed
secsys-go opened this issue Jun 21, 2022 · 2 comments
Closed

Comments

@secsys-go
Copy link

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

$ go version
go version go1.17.8 linux/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
GO111MODULE="auto"
GOARCH="amd64"
GOBIN="/home/zjx/workspace/gowork/bin"
GOCACHE="/home/zjx/.cache/go-build"
GOENV="/home/zjx/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zjx/workspace/gowork/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zjx/workspace/gowork"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/home/zjx/.local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/zjx/.local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.8"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/zjx/workspace/gowork/src/go-fdg-exmaples/std/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1878510231=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I generated an unavailable data to parse as txtar.Archive, and it crashed.

package main

import (
	"cmd/go/internal/txtar"
)

func main() {
	input := "--\n-- --\n--"
	txtar.Parse([]byte(input))
}

This code needs to run in GOROOT/src

What did you expect to see?

It parses failed and returns nil

What did you see instead?

It crashed with

panic: runtime error: slice bounds out of range [3:2]

goroutine 1 [running]:
cmd/go/internal/txtar.isMarker({0xc000016083, 0x8, 0xd})
        /home/zjx/.local/go/src/cmd/go/internal/txtar/archive.go:127 +0x20b
cmd/go/internal/txtar.findFileMarker({0xc000016080, 0xb, 0x10})
        /home/zjx/.local/go/src/cmd/go/internal/txtar/archive.go:103 +0x86
cmd/go/internal/txtar.Parse({0xc000016080, 0xb, 0x10})
        /home/zjx/.local/go/src/cmd/go/internal/txtar/archive.go:81 +0x6c
main.main()
        /home/zjx/.local/go/src/cmd/go/internal/fsys/poc/main.go:9 +0x2c
exit status 2

Found by go-fuzz

@ZekeLu
Copy link
Contributor

ZekeLu commented Jun 21, 2022

The issue should have been fixed by golang/tools@ebce39e. See also #47193.

@ianlancetaylor
Copy link
Contributor

Closing as dup of #47193. Please comment if you disagree.

@ianlancetaylor ianlancetaylor closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2022
@golang golang locked and limited conversation to collaborators Jun 21, 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

4 participants