Currently, the DMG reader treats all Comment, Ignore, and Zero block chunks as an array of 0s of length compressed_bytes.
When reading DMGs produced by Apple's tooling, I was seeing corrupted partition data that coincided with the reading of Ignore and Zero block chunks. The following patch seems to fix things:
However, applying this patch causes tests to fail. Specifically the only_read_dmg test. This test attempts to create a copy of the vendored example.dmg file and verify it roundtrips properly. The test fails because the checksums differ:
for i in 0..dmg.plist().partitions().len() {
let table = dmg.partition_table(i)?;
let data = dmg.partition_data(i)?;
let expected = u32::from(table.checksum);
let calculated = crc32fast::hash(&data);
assert_eq!(expected, calculated);
}
And the checksums differ because the code change causes the emitted partition data to change, which changes the checksum.
@dvc94ch can you provide insight on how example.dmg was created? Was it created via Apple's tooling or this repo's Rust code? If it was produced with our Rust code, I think the checksums may be wrong. But without knowing what is supposed to be in the partition data, I can't (easily) pinpoint bugs in the DMG code.
Currently, the DMG reader treats all
Comment
,Ignore
, andZero
block chunks as an array of 0s of lengthcompressed_bytes
.When reading DMGs produced by Apple's tooling, I was seeing corrupted partition data that coincided with the reading of
Ignore
andZero
block chunks. The following patch seems to fix things:However, applying this patch causes tests to fail. Specifically the
only_read_dmg
test. This test attempts to create a copy of the vendoredexample.dmg
file and verify it roundtrips properly. The test fails because the checksums differ:And the checksums differ because the code change causes the emitted partition data to change, which changes the checksum.
@dvc94ch can you provide insight on how
example.dmg
was created? Was it created via Apple's tooling or this repo's Rust code? If it was produced with our Rust code, I think the checksums may be wrong. But without knowing what is supposed to be in the partition data, I can't (easily) pinpoint bugs in the DMG code.