From d3b817b95c39d44b94346fa4da3476157f255b91 Mon Sep 17 00:00:00 2001 From: Amit Barve Date: Tue, 13 Oct 2020 22:25:17 -0700 Subject: [PATCH] Read trailing data from tar reader Not reading all the data from the tar reader causes the layer digest mismatch which causes failures during unpack of certain images for lcow. This changes fixes that. Signed-off-by: Amit Barve --- diff/lcow/lcow.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/diff/lcow/lcow.go b/diff/lcow/lcow.go index 4c5d74ca3..344aa7eb0 100644 --- a/diff/lcow/lcow.go +++ b/diff/lcow/lcow.go @@ -21,6 +21,7 @@ package lcow import ( "context" "io" + "io/ioutil" "os" "path" "time" @@ -163,6 +164,11 @@ func (s windowsLcowDiff) Apply(ctx context.Context, desc ocispec.Descriptor, mou } outFile.Close() + // Read any trailing data + if _, err := io.Copy(ioutil.Discard, rc); err != nil { + return emptyDesc, err + } + err = security.GrantVmGroupAccess(layerPath) if err != nil { return emptyDesc, errors.Wrapf(err, "failed GrantVmGroupAccess on layer vhd: %v", layerPath)