Skip to content

Commit 24d459f

Browse files
committed
Ignore size value from GetBlob
The internal API in containers/image returns a size...which is an `int64` in the source probably because OCI Descriptor type have it be an int64 too for bad historical reasons; xref opencontainers/image-spec#153 Anyways, the `GetBlob` wrapper API returns `-1` when the remote registry doesn't emit `Content-Length`: https://github.com/containers/container-libs/blob/3af9abd27f3b875122b9fedd88953e8c840d6958/image/docker/docker_client.go#L1068 And this apparently happens with at least the Quay mirror registry. We also noticed this problem when adding `GetRawBlob` in containers/skopeo#2601 which simply doesn't return a size to the client at all. Signed-off-by: Colin Walters <[email protected]>
1 parent 3b2bc1d commit 24d459f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/imageproxy.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,12 @@ impl ImageProxy {
646646
tracing::debug!("fetching blob");
647647
let args: Vec<serde_json::Value> =
648648
vec![img.0.into(), digest.to_string().into(), size.into()];
649-
let (bloblen, pipe): (u64, FinishPipe) =
649+
// Note that size may be -1 here if e.g. the remote registry doesn't give a Content-Length
650+
// for example.
651+
// We have always validated the size later (in FinishPipe) so out of conservatism we
652+
// just ignore the size here.
653+
let (_bloblen, pipe): (serde_json::Number, FinishPipe) =
650654
self.impl_request_with_fds("GetBlob", args).await?;
651-
let _: u64 = bloblen;
652655
let fd = tokio::fs::File::from_std(std::fs::File::from(pipe.datafd));
653656
let fd = tokio::io::BufReader::new(fd);
654657
let finish = Box::pin(self.finish_pipe(pipe.pipeid));

0 commit comments

Comments
 (0)