Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Panic on parsing malformed dockerfile (2) #271

Closed
bayandin opened this issue Sep 25, 2019 · 1 comment · Fixed by #273
Closed

Panic on parsing malformed dockerfile (2) #271

bayandin opened this issue Sep 25, 2019 · 1 comment · Fixed by #273
Labels
bug Something isn't working

Comments

@bayandin
Copy link

Thanks for fixing #266!

Describe the bug

I've found a couple of more panics by go-fuzz:

To Reproduce

  1. FROM 0\nCOPY \xa0:
// +build ignore

package main

import (
	"github.com/uber/makisu/lib/parser/dockerfile"
)

func main() {
	data := string([]byte("FROM 0\nCOPY \xa0"))

	dockerfile.ParseFile(data, map[string]string{})
}

fails with

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/uber/makisu/lib/parser/dockerfile.newCopyDirective(0xc00009a2a0, 0xc00009a1e0, 0xc0000980dc, 0x4, 0xc00009e860, 0xc000098001)
	/Users/bayandin/go/src/github.com/uber/makisu/lib/parser/dockerfile/copy.go:39 +0x6a3
github.com/uber/makisu/lib/parser/dockerfile.newDirective(0xc0000980d4, 0x6, 0xc00009a1e0, 0xff9, 0xc0000980d4, 0x6, 0x0)
	/Users/bayandin/go/src/github.com/uber/makisu/lib/parser/dockerfile/directive.go:59 +0x1be
github.com/uber/makisu/lib/parser/dockerfile.ParseFile(0xc000098002, 0xd, 0xc00009a180, 0xd, 0xc000098002, 0xd, 0xc000016118, 0x0)
	/Users/bayandin/go/src/github.com/uber/makisu/lib/parser/dockerfile/parse_file.go:42 +0x2b7
main.main()
	/Users/bayandin/go/src/github.com/uber/makisu/lib/parser/dockerfile/test.go:12 +0xa2
exit status 2
  1. FROM \x85
// +build ignore

package main

import (
	"github.com/uber/makisu/lib/parser/dockerfile"
)

func main() {
	data := string([]byte("FROM \x85"))

	dockerfile.ParseFile(data, map[string]string{})
}

fails with

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/uber/makisu/lib/parser/dockerfile.newFromDirective(0xc000076360, 0xc000076330, 0xc00009e088, 0x4, 0xc000085680, 0xc00009e001)
	/Users/bayandin/go/src/github.com/uber/makisu/lib/parser/dockerfile/from.go:49 +0x30f
github.com/uber/makisu/lib/parser/dockerfile.newDirective(0xc00009e080, 0x6, 0xc000076330, 0x1000, 0xc00009e080, 0x6, 0xffffffffffffffff)
	/Users/bayandin/go/src/github.com/uber/makisu/lib/parser/dockerfile/directive.go:59 +0x1be
github.com/uber/makisu/lib/parser/dockerfile.ParseFile(0xc00009e002, 0x6, 0xc0000762d0, 0x6, 0xc00009e002, 0x6, 0x0, 0x0)
	/Users/bayandin/go/src/github.com/uber/makisu/lib/parser/dockerfile/parse_file.go:42 +0x2b7
main.main()
	/Users/bayandin/go/src/github.com/uber/makisu/lib/parser/dockerfile/test.go:12 +0x93
exit status 2

Expected behaviour
A proper error message that dockerfile is malformed

Additional context
makisu version is 27daadc

@yiranwang52 yiranwang52 added the bug Something isn't working label Sep 26, 2019
@yiranwang52
Copy link
Collaborator

Thanks for helping us finding these issues!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants