From 24d459fa655d84f80c69849c4c5ec5985f6312fa Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 4 Sep 2025 12:15:33 -0400 Subject: [PATCH] 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 https://github.com/opencontainers/image-spec/pull/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 https://github.com/containers/skopeo/pull/2601 which simply doesn't return a size to the client at all. Signed-off-by: Colin Walters --- src/imageproxy.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/imageproxy.rs b/src/imageproxy.rs index 4638582..da30db5 100644 --- a/src/imageproxy.rs +++ b/src/imageproxy.rs @@ -646,9 +646,12 @@ impl ImageProxy { tracing::debug!("fetching blob"); let args: Vec = vec![img.0.into(), digest.to_string().into(), size.into()]; - let (bloblen, pipe): (u64, FinishPipe) = + // Note that size may be -1 here if e.g. the remote registry doesn't give a Content-Length + // for example. + // We have always validated the size later (in FinishPipe) so out of conservatism we + // just ignore the size here. + let (_bloblen, pipe): (serde_json::Number, FinishPipe) = self.impl_request_with_fds("GetBlob", args).await?; - let _: u64 = bloblen; let fd = tokio::fs::File::from_std(std::fs::File::from(pipe.datafd)); let fd = tokio::io::BufReader::new(fd); let finish = Box::pin(self.finish_pipe(pipe.pipeid));