diff --git a/vendor/github.com/containers/image/oci/oci_dest.go b/vendor/github.com/containers/image/oci/oci_dest.go index 163d5004..6dd7f46e 100644 --- a/vendor/github.com/containers/image/oci/oci_dest.go +++ b/vendor/github.com/containers/image/oci/oci_dest.go @@ -96,7 +96,11 @@ func (d *ociImageDestination) PutManifest(m []byte) error { return err } - if err := ioutil.WriteFile(d.ref.blobPath(digest), ociMan, 0644); err != nil { + blobPath, err := d.ref.blobPath(digest) + if err != nil { + return err + } + if err := ioutil.WriteFile(blobPath, ociMan, 0644); err != nil { return err } // TODO(runcom): ugly here? @@ -116,7 +120,10 @@ func (d *ociImageDestination) PutManifest(m []byte) error { // If stream.Read() at any time, ESPECIALLY at end of input, returns an error, PutBlob MUST 1) fail, and 2) delete any data stored so far. // Note: Calling PutBlob() and other methods may have ordering dependencies WRT other methods of this type. FIXME: Figure out and document. func (d *ociImageDestination) PutBlob(digest string, stream io.Reader) error { - blobPath := d.ref.blobPath(digest) + blobPath, err := d.ref.blobPath(digest) + if err != nil { + return err + } if err := ensureParentDirectoryExists(blobPath); err != nil { return err } diff --git a/vendor/github.com/containers/image/oci/oci_transport.go b/vendor/github.com/containers/image/oci/oci_transport.go index e6d92a39..26ba4cbd 100644 --- a/vendor/github.com/containers/image/oci/oci_transport.go +++ b/vendor/github.com/containers/image/oci/oci_transport.go @@ -192,8 +192,12 @@ func (ref ociReference) ociLayoutPath() string { } // blobPath returns a path for a blob within a directory using OCI image-layout conventions. -func (ref ociReference) blobPath(digest string) string { - return filepath.Join(ref.dir, "blobs", strings.Replace(digest, ":", "-", -1)) +func (ref ociReference) blobPath(digest string) (string, error) { + pts := strings.SplitN(digest, ":", 2) + if len(pts) != 2 { + return "", fmt.Errorf("unexpected digest reference %s", digest) + } + return filepath.Join(ref.dir, "blobs", pts[0], pts[1]), nil } // descriptorPath returns a path for the manifest within a directory using OCI conventions.