Skip to content

Commit b2cf85a

Browse files
committed
Check whether algorithm is available
1 parent 4649371 commit b2cf85a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

image/oci/layout/oci_src.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,14 @@ func (s *ociImageSource) GetSignaturesWithFormat(ctx context.Context, instanceDi
278278
if err != nil {
279279
return nil, fmt.Errorf("reading blob %s in %s: %w", layer.Digest.String(), instanceDigest, err)
280280
}
281-
actualDigest := layer.Digest.Algorithm().FromBytes(payload)
281+
if err := layer.Digest.Validate(); err != nil {
282+
return nil, fmt.Errorf("invalid digest %q: %w", layer.Digest, err)
283+
}
284+
digestAlgorithm := layer.Digest.Algorithm()
285+
if !digestAlgorithm.Available() {
286+
return nil, fmt.Errorf("invalid digest %q: unsupported digest algorithm %q", layer.Digest.String(), digestAlgorithm.String())
287+
}
288+
actualDigest := digestAlgorithm.FromBytes(payload)
282289
if actualDigest != layer.Digest {
283290
return nil, fmt.Errorf("digest mismatch, expected %q, got %q", layer.Digest.String(), actualDigest.String())
284291
}

0 commit comments

Comments
 (0)