mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
fix(artifacts): accept Android boot images without final page padding (#11857)
* fix(artifacts): accept Android boot images without final page padding The truncation check required the file to reach the page-aligned end after the last component, so an image holding every declared byte but omitting the trailing zero padding was refused as truncated, and the message named the padded end. Bound truncation by the last declared header or component byte instead, keep the page-aligned end for locating an AVB footer, and check the AVB original image size against the declared bytes. Fixes #11854 * test(artifacts): check boot image declared ends against the fixture layout Derive each expected end from the fixture layout instead of the parser's dataEnd, so a declared structure dropped from the coverage check fails the test. --------- Co-authored-by: Anurag Singh <211784907+Anurag-5ingh@users.noreply.github.com>
This commit is contained in:
1 parent
84ee604c6d
commit
bb5278c7e2
7 files changed
+192
-17
No files matched your search
@@ -292,6 +292,31 @@ it("records an AVB footer without treating it as a child", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("inventories an image whose final page padding is absent", async () => {
|
||||
const kernel = Buffer.from("kernel-bytes");
|
||||
const ramdisk = Buffer.from("ramdisk-bytes");
|
||||
const padded = buildBootImage({ version: 0, kernel, ramdisk });
|
||||
// The ramdisk starts on page 2; drop only the zero padding after it.
|
||||
const unpadded = padded.subarray(0, 4096 + ramdisk.length);
|
||||
expect(padded.subarray(unpadded.length).every((byte) => byte === 0)).toBe(
|
||||
true,
|
||||
);
|
||||
const path = await writeCarrier("unpadded.img", unpadded);
|
||||
const snapshot = await scanCanonicalArtifactInventory(path);
|
||||
expect(snapshot.coverage.status).toBe("complete");
|
||||
expect(
|
||||
snapshot.occurrences.find((row) => row.logical_path === ".")
|
||||
?.format_metadata,
|
||||
).toMatchObject({
|
||||
component_count: 2,
|
||||
avb_footer_present: false,
|
||||
avb_footer_size: null,
|
||||
});
|
||||
const stored = await openAll(path);
|
||||
expect(stored.get("kernel")?.equals(kernel)).toBe(true);
|
||||
expect(stored.get("ramdisk")?.equals(ramdisk)).toBe(true);
|
||||
});
|
||||
|
||||
it("fails closed on truncation and overlapping ranges", async () => {
|
||||
const truncated = await writeCarrier(
|
||||
"truncated.img",
|
||||
|
||||
Reference in new issue
Block a user