mirror of
https://github.com/chenxiaolong/avbroot.git
synced 2026-06-02 06:23:34 +02:00
Add support for packing and unpacking Android sparse images
This supports all features of Android sparse images, including holes, and CRC32 (both full image checksum and CRC32 chunks). Partial sparse images, like those included in GrapheneOS' new optimized factory images, can also be packed and unpacked with these new commands, unlike AOSP's simg2img and img2simg tools. This new functionality is not relevant for avbroot's main use case, but is useful for unpacking certain factory images for comparison with OTAs during troubleshooting. Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#[cfg(not(windows))]
|
||||
mod fuzz {
|
||||
use std::io::{self, Cursor};
|
||||
|
||||
use avbroot::format::sparse::{ChunkData, CrcMode, SparseReader};
|
||||
use honggfuzz::fuzz;
|
||||
|
||||
pub fn main() {
|
||||
loop {
|
||||
fuzz!(|data: &[u8]| {
|
||||
let reader = Cursor::new(data);
|
||||
if let Ok(mut sparse_reader) = SparseReader::new(reader, CrcMode::Ignore) {
|
||||
while let Ok(Some(chunk)) = sparse_reader.next_chunk() {
|
||||
if chunk.data == ChunkData::Data {
|
||||
let _ = io::copy(&mut sparse_reader, &mut io::sink());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
#[cfg(not(windows))]
|
||||
fuzz::main();
|
||||
}
|
||||
Reference in New Issue
Block a user