Panic on parsing malformed dockerfile (2)
bayandin opened this issue · 1 comments
bayandin commented
Thanks for fixing #266!
Describe the bug
I've found a couple of more panics by go-fuzz:
To Reproduce
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
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 commented
Thanks for helping us finding these issues!