Skip to content

magiskboot: fix ZERO operation handling in payload extraction - #10282

Open
lingyicute wants to merge 1 commit into
topjohnwu:masterfrom
lingyicute:master
Open

lingyicute wants to merge 1 commit into
topjohnwu:masterfrom
lingyicute:master

Conversation

@lingyicute

Copy link
Copy Markdown

Fixes two bugs when handling InstallOperation::ZERO in extract_boot_from_payload:

  1. Handle Type::ZERO before reading data_length and data_offset:
    Per update_metadata.proto, ZERO operations only specify dst_extents and do not have an associated data blob in the payload (data_offset and data_length are None). Previously, extract_boot_from_payload unconditionally unwrapped data_length and data_offset at the beginning of the loop before checking operation.type_pb, causing extraction to fail with Invalid payload: data length not found on any payload containing a ZERO operation.

  2. Multiply num_blocks by block_size when writing zeros:
    Extent.num_blocks is measured in blocks, whereas WriteExt::write_zeros takes the number of bytes to write. Previously num_blocks was passed directly as the byte length instead of num_blocks * block_size.

In OTA payloads, InstallOperation::ZERO operations do not carry a data
blob in the payload file, so data_offset and data_length are not set in
the manifest. Checking data_length and data_offset before matching the
operation type causes extraction to fail with "data length not found"
whenever a ZERO operation is encountered.

In addition, write_zeros() expects a byte count, so num_blocks must be
multiplied by block_size.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant