validate image ID properly & before load

Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
Upstream-commit: acf1720b3f6035f0ab2c9658371ae8302851ffa3
Component: engine
This commit is contained in:
unclejack
2014-11-27 23:55:03 +02:00
committed by Tibor Vass
parent 94c64ce8e8
commit ed1287419c
4 changed files with 15 additions and 8 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/docker/docker/pkg/archive"
"github.com/docker/docker/pkg/chrootarchive"
"github.com/docker/docker/pkg/log"
"github.com/docker/docker/utils"
)
// Loads a set of images into the repository. This is the complementary of ImageExport.
@ -112,6 +113,10 @@ func (s *TagStore) recursiveLoad(eng *engine.Engine, address, tmpImageDir string
log.Debugf("Error unmarshalling json", err)
return err
}
if err := utils.ValidateID(img.ID); err != nil {
log.Debugf("Error validating ID: %s", err)
return err
}
if img.Parent != "" {
if !s.graph.Exists(img.Parent) {
if err := s.recursiveLoad(eng, img.Parent, tmpImageDir); err != nil {

View File

@ -16,7 +16,7 @@ import (
const (
testImageName = "myapp"
testImageID = "foo"
testImageID = "1a2d3c4d4e5fa2d2a21acea242a5e2345d3aefc3e7dfa2a2a2a21a2a2ad2d234"
)
func fakeTar() (io.Reader, error) {