From 6875c9fbcf1cb6e06ee5e363982a059adec9693b Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 3 Jun 2024 13:44:45 +0200 Subject: [PATCH] chunked: ignore the tar-split data if digest is empty if a digest was not specified in the TOC, ignore completely the tar-split data. Otherwise the clients fail to pull images created before commit b5413c2bd64742a08384300f09616a66231b21d1. Signed-off-by: Giuseppe Scrivano --- pkg/chunked/compression_linux.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/pkg/chunked/compression_linux.go b/pkg/chunked/compression_linux.go index 7b3879a994..01af0e834e 100644 --- a/pkg/chunked/compression_linux.go +++ b/pkg/chunked/compression_linux.go @@ -210,14 +210,18 @@ func readZstdChunkedManifest(blobStream ImageSourceSeekable, tocDigest digest.Di decodedTarSplit := []byte{} if tarSplitChunk.Offset > 0 { - tarSplit, err := readBlob(tarSplitChunk.Length) - if err != nil { - return nil, nil, nil, 0, err - } - - 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) + 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 + } + + 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) + } } } return decodedBlob, toc, decodedTarSplit, int64(manifestChunk.Offset), err