1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #15664 from skatsuta/fix-parse-null

builder: avoid parsing null- string to nil slice (issue #15634)
This commit is contained in:
Doug Davis 2015-08-19 09:06:20 -07:00
commit ca79576585
4 changed files with 32 additions and 0 deletions

View file

@ -232,6 +232,11 @@ func parseString(rest string) (*Node, map[string]bool, error) {
// parseJSON converts JSON arrays to an AST.
func parseJSON(rest string) (*Node, map[string]bool, error) {
rest = strings.TrimLeftFunc(rest, unicode.IsSpace)
if !strings.HasPrefix(rest, "[") {
return nil, nil, fmt.Errorf(`Error parsing "%s" as a JSON array`, rest)
}
var myJSON []interface{}
if err := json.NewDecoder(strings.NewReader(rest)).Decode(&myJSON); err != nil {
return nil, nil, err

View file

@ -3,6 +3,8 @@ MAINTAINER Seongyeol Lim <seongyeol37@gmail.com>
COPY . /go/src/github.com/docker/docker
ADD . /
ADD null /
COPY nullfile /tmp
ADD [ "vimrc", "/tmp" ]
COPY [ "bashrc", "/tmp" ]
COPY [ "test file", "/tmp" ]

View file

@ -2,6 +2,8 @@
(maintainer "Seongyeol Lim <seongyeol37@gmail.com>")
(copy "." "/go/src/github.com/docker/docker")
(add "." "/")
(add "null" "/")
(copy "nullfile" "/tmp")
(add "vimrc" "/tmp")
(copy "bashrc" "/tmp")
(copy "test file" "/tmp")

View file

@ -5444,3 +5444,26 @@ func (s *DockerTrustSuite) TestBuildContextDirIsSymlink(c *check.C) {
c.Fatalf("build failed with exit status %d: %s", exitStatus, out)
}
}
// Issue #15634: COPY fails when path starts with "null"
func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) {
name := "testbuildnullstringinaddcopyvolume"
ctx, err := fakeContext(`
FROM busybox
ADD null /
COPY nullfile /
VOLUME nullvolume
`,
map[string]string{
"null": "test1",
"nullfile": "test2",
},
)
defer ctx.Close()
c.Assert(err, check.IsNil)
_, err = buildImageFromContext(name, ctx, true)
c.Assert(err, check.IsNil)
}