chunked: fix deadlock by always consuming tar-split

always consume the tar-split data when present to avoid blocking the
producer. Previously, the tar-split data was only read when the digest
was specified.

commit 6875c9fbcf introduced the
regression.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2024-06-03 22:43:53 +02:00
parent 9661c8f9f8
commit 4595fa2aab
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772
1 changed files with 7 additions and 8 deletions

View File

@ -210,14 +210,13 @@ func readZstdChunkedManifest(blobStream ImageSourceSeekable, tocDigest digest.Di
decodedTarSplit := []byte{}
if tarSplitChunk.Offset > 0 {
tarSplitDigest := toc.TarSplitDigest.String()
// ignore the tar-split data if the digest was not specified
if tarSplitDigest != "" {
tarSplit, err := readBlob(tarSplitChunk.Length)
if err != nil {
return nil, nil, nil, 0, err
}
// we must consume the data to not block the producer
tarSplit, err := readBlob(tarSplitChunk.Length)
if err != nil {
return nil, nil, nil, 0, err
}
// but ignore it when the digest is not present, because we cant authenticate it against tocDigest
if toc.TarSplitDigest != "" {
decodedTarSplit, err = decodeAndValidateBlob(tarSplit, tarSplitLengthUncompressed, toc.TarSplitDigest.String())
if err != nil {
return nil, nil, nil, 0, fmt.Errorf("validating and decompressing tar-split: %w", err)