Skip to content

Commit

Permalink
magiskboot: add simple workaround for Samsung offset header variant
Browse files Browse the repository at this point in the history
- some Samsung devices (e.g. Galaxy S5 SMG-900H) use a slightly different AOSP bootimg.h variant with `#define BOOT_NAME_SIZE 20` instead of 16
- since all known examples of these device images do not have anything in the NAME or CMDLINE fields, and the bootloader also accepts standard AOSP images, simply offset the SHA1/SHA256 detection by 4 bytes to avoid false positives from these images, remain an equally effective detection shortcut, and ensure a proper SHA1 checksum on repack

aosp-dtbhdt2-4offhash-seandroid-256sig-samsung_gs5-smg900h-boot.img
UNPACK CHECKSUM [00000000b11580f7d20f70297cdc31e02626def0356c82b90000000000000000]
REPACK CHECKSUM [73b18751202e56c433f89dfd1902c290eaf4eef3e167fcf03b814b59a5e984b6]
AIK CHECKSUM    [b11580f7d20f70297cdc31e02626def0356c82b9000000000000000000000000]

This patch should result in a `magiskboot unpack -n boot.img; magiskboot repack boot.img` new-boot.img matching the AIK CHECKSUM above.
  • Loading branch information
osm0sis authored and topjohnwu committed Nov 16, 2019
1 parent 44ed0a3 commit 7f6a601
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion native/jni/magiskboot/bootimg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ void boot_img::parse_image(uint8_t *addr) {
hdr = new dyn_img_v0(addr);
}

for (int i = SHA_DIGEST_SIZE; i < SHA256_DIGEST_SIZE; ++i) {
for (int i = SHA_DIGEST_SIZE + 4; i < SHA256_DIGEST_SIZE; ++i) {
if (hdr->id()[i]) {
flags |= SHA256_FLAG;
break;
Expand Down

0 comments on commit 7f6a601

Please sign in to comment.