Skip to content

Commit 7b76131

Browse files
vdemeestertekton-robot
authored andcommitted
Use io.ReadFull to read the bundle content
The io.Reader documentation says: > Read reads up to len(p) bytes into p. It returns the number of bytes > read (0 <= n <= len(p)) and any error encountered. ... If some data is > available but not len(p) bytes, Read conventionally returns what is > available instead of waiting for more. Read is not guaranteed to fill the data argument. Use io.ReadFull to fill the buffer. In some cases (a relatively big bundle), the bundle content was not completely read and it would fail to parse. Using `io.ReadFull` fixes the issue. Signed-off-by: Vincent Demeester <[email protected]>
1 parent 9664cb4 commit 7b76131

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/resolution/resolver/bundle/bundle.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func readTarLayer(layer v1.Layer) ([]byte, error) {
194194
}
195195

196196
contents := make([]byte, header.Size)
197-
if _, err := treader.Read(contents); err != nil && !errors.Is(err, io.EOF) {
197+
if _, err := io.ReadFull(treader, contents); err != nil && err != io.EOF {
198198
// We only allow 1 resource per layer so this tar bundle should have one and only one file.
199199
return nil, fmt.Errorf("failed to read tar bundle: %w", err)
200200
}

0 commit comments

Comments
 (0)