Decide on tar-split usage based on trusted data in TOC
Don't ignore the tar-split when the TOC requires one, otherwise we could deduplicate a layer without tar-split with a layer with tar-split. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
c193a4503f
commit
f065a0a81c
|
|
@ -209,18 +209,26 @@ func readZstdChunkedManifest(blobStream ImageSourceSeekable, tocDigest digest.Di
|
||||||
}
|
}
|
||||||
|
|
||||||
decodedTarSplit := []byte{}
|
decodedTarSplit := []byte{}
|
||||||
if tarSplitChunk.Offset > 0 {
|
if toc.TarSplitDigest != "" {
|
||||||
// we must consume the data to not block the producer
|
if tarSplitChunk.Offset <= 0 {
|
||||||
|
return nil, nil, nil, 0, fmt.Errorf("TOC requires a tar-split, but the %s annotation does not describe a position", internal.TarSplitInfoKey)
|
||||||
|
}
|
||||||
tarSplit, err := readBlob(tarSplitChunk.Length)
|
tarSplit, err := readBlob(tarSplitChunk.Length)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, 0, err
|
return nil, nil, nil, 0, err
|
||||||
}
|
}
|
||||||
// but ignore it when the digest is not present, because we can’t authenticate it against tocDigest
|
decodedTarSplit, err = decodeAndValidateBlob(tarSplit, tarSplitLengthUncompressed, toc.TarSplitDigest.String())
|
||||||
if toc.TarSplitDigest != "" {
|
if err != nil {
|
||||||
decodedTarSplit, err = decodeAndValidateBlob(tarSplit, tarSplitLengthUncompressed, toc.TarSplitDigest.String())
|
return nil, nil, nil, 0, fmt.Errorf("validating and decompressing tar-split: %w", err)
|
||||||
if err != nil {
|
}
|
||||||
return nil, nil, nil, 0, fmt.Errorf("validating and decompressing tar-split: %w", err)
|
} else if tarSplitChunk.Offset > 0 {
|
||||||
}
|
// We must ignore the tar-split when the digest is not present in the TOC, because we can’t authenticate it.
|
||||||
|
//
|
||||||
|
// But if we asked for the chunk, now we must consume the data to not block the producer.
|
||||||
|
// Ideally the GetBlobAt API should be changed so that this is not necessary.
|
||||||
|
_, err := readBlob(tarSplitChunk.Length)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return decodedBlob, toc, decodedTarSplit, int64(manifestChunk.Offset), err
|
return decodedBlob, toc, decodedTarSplit, int64(manifestChunk.Offset), err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue