Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rafs: fix a incorrect mapped_blkaddr for multi layer images #1184

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions rafs/src/builder/core/v6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::metadata::RafsStore;
use crate::RafsIoWrite;

const WRITE_PADDING_DATA: [u8; 4096] = [0u8; 4096];
const V6_BLOCK_SEG_ALIGNMENT: u64 = 0x20_0000;
const V6_BLOCK_SEG_ALIGNMENT: u64 = 0x8_0000;

// Rafs v6 dedicated methods
impl Node {
Expand Down Expand Up @@ -764,7 +764,7 @@ impl Bootstrap {
"blob id length is bigger than 64 bytes, blob id {:?}",
entry.blob_id()
));
} else if entry.uncompressed_size() / ctx.v6_block_size() > u32::MAX as u64 {
} else if entry.uncompressed_size() / block_size > u32::MAX as u64 {
bail!(format!(
"uncompressed blob size (0x:{:x}) is too big",
entry.uncompressed_size()
Expand All @@ -773,12 +773,12 @@ impl Bootstrap {
if !entry.has_feature(BlobFeatures::INLINED_CHUNK_DIGEST) {
inlined_chunk_digest = false;
}
let cnt = (entry.uncompressed_size() / ctx.v6_block_size()) as u32;
let cnt = (entry.uncompressed_size() / block_size) as u32;
if block_count.checked_add(cnt).is_none() {
bail!("Too many data blocks in RAFS filesystem, block size 0x{:x}, block count 0x{:x}", ctx.v6_block_size(), block_count as u64 + cnt as u64);
bail!("Too many data blocks in RAFS filesystem, block size 0x{:x}, block count 0x{:x}", block_size, block_count as u64 + cnt as u64);
}
let mapped_blkaddr = Self::v6_align_mapped_blkaddr(block_size, pos)?;
pos += cnt as u64 * ctx.v6_block_size();
pos = (mapped_blkaddr + cnt) as u64 * block_size;
block_count += cnt;

let id = entry.blob_id();
Expand Down