Skip to content

Commit

Permalink
chunked: validate number of chunks received
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed May 11, 2022
1 parent 10d3891 commit 90fd24c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/chunked/storage_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,9 @@ func (c *chunkedDiffer) storeMissingFiles(streams chan io.ReadCloser, errs chan
case p := <-streams:
part = p
case err := <-errs:
if err == nil {
return errors.New("not enough data returned from the server")
}
return err
}
if part == nil {
Expand Down Expand Up @@ -1575,6 +1578,8 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions) (gra
wg.Wait()

for _, res := range copyResults[:filesToWaitFor] {
r := &mergedEntries[res.index]

if res.err != nil {
return output, res.err
}
Expand All @@ -1584,8 +1589,6 @@ func (c *chunkedDiffer) ApplyDiff(dest string, options *archive.TarOptions) (gra
continue
}

r := &mergedEntries[res.index]

missingPartsSize += r.Size

remainingSize := r.Size
Expand Down

0 comments on commit 90fd24c

Please sign in to comment.