Skip to content

Commit

Permalink
builder: fix invalid compressed offset in image.blob toc entry
Browse files Browse the repository at this point in the history
The `blob_ctx.compressed_offset` has been set to the end of compressed
blob in tar2rafs blob dump, we shouldn't use it as the initial
compressed_offset, this will generate an invalid toc entry.

Signed-off-by: Yan Song <imeoer@linux.alibaba.com>
  • Loading branch information
imeoer committed Feb 21, 2023
1 parent aea56eb commit ab7f2b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bin/nydus-image/core/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Blob {
toc::TOC_ENTRY_BLOB_RAW,
compress::Algorithm::None,
blob_digest,
blob_ctx.compressed_offset,
blob_ctx.begin_compressed_offset(),
blob_ctx.compressed_blob_size,
blob_ctx.uncompressed_blob_size,
)?;
Expand Down
6 changes: 6 additions & 0 deletions src/bin/nydus-image/core/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,12 @@ impl BlobContext {
self.blob_hash.update(header.as_bytes());
Ok(header)
}

/// Get begin offset of compressed blob, since compressed_offset
/// is always >= compressed_blob_size, we can safely subtract here.
pub fn begin_compressed_offset(&self) -> u64 {
self.compressed_offset - self.compressed_blob_size
}
}

/// BlobManager stores all blob related information during build.
Expand Down

0 comments on commit ab7f2b9

Please sign in to comment.