From 17e234f9d5176f79d5adbc1d3bfde126cfe0e6fe Mon Sep 17 00:00:00 2001 From: Chris Renshaw Date: Mon, 20 May 2019 20:57:49 -0300 Subject: [PATCH 1/3] magiskboot: fix bootimg hdr v2 checksum generation - new AOSP dtb section was missing from HASH_update --- native/jni/magiskboot/bootimg.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/native/jni/magiskboot/bootimg.cpp b/native/jni/magiskboot/bootimg.cpp index f46f1b32c..4057afb3f 100644 --- a/native/jni/magiskboot/bootimg.cpp +++ b/native/jni/magiskboot/bootimg.cpp @@ -345,7 +345,7 @@ int unpack(const char *image, bool hdr) { void repack(const char* orig_image, const char* out_image) { boot_img boot {}; - off_t header_off, kernel_off, ramdisk_off, second_off, extra_off; + off_t header_off, kernel_off, ramdisk_off, second_off, extra_off, dtb_off; // Parse original image boot.parse_file(orig_image); @@ -475,6 +475,7 @@ void repack(const char* orig_image, const char* out_image) { } // dtb + dtb_off = lseek(fd, 0, SEEK_CUR); if (access(DTB_FILE, R_OK) == 0) { boot.hdr.dtb_size() = restore(DTB_FILE, fd); file_align(); @@ -527,6 +528,11 @@ void repack(const char* orig_image, const char* out_image) { size = boot.hdr.recovery_dtbo_size(); HASH_update(&ctx, boot.map_addr + boot.hdr.recovery_dtbo_offset(), size); HASH_update(&ctx, &size, sizeof(size)); + size = boot.hdr.dtb_size(); + if (size) { + HASH_update(&ctx, boot.map_addr + dtb_off, size); + HASH_update(&ctx, &size, sizeof(size)); + } } memset(boot.hdr.id(), 0, 32); memcpy(boot.hdr.id(), HASH_final(&ctx), From b79d1bcded5842ab6d9cc663b4ab2ebb7fac0e72 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Mon, 20 May 2019 22:27:36 -0300 Subject: [PATCH 2/3] magiskboot: clean up remaining unneeded ELF detection bits - default for no format match is UNSUPP_RET (unsupported) so there is no needed to explicitly detect ELF still --- native/jni/magiskboot/bootimg.cpp | 4 ---- native/jni/magiskboot/format.cpp | 4 ---- native/jni/magiskboot/format.h | 4 ---- 3 files changed, 12 deletions(-) diff --git a/native/jni/magiskboot/bootimg.cpp b/native/jni/magiskboot/bootimg.cpp index 4057afb3f..07ba2e160 100644 --- a/native/jni/magiskboot/bootimg.cpp +++ b/native/jni/magiskboot/bootimg.cpp @@ -90,10 +90,6 @@ int boot_img::parse_file(const char *image) { case AOSP: return parse_image(head); - /* Unsupported */ - case ELF32: - case ELF64: - exit(UNSUPP_RET); default: break; } diff --git a/native/jni/magiskboot/format.cpp b/native/jni/magiskboot/format.cpp index 9c5f56a11..eda3ceaa7 100644 --- a/native/jni/magiskboot/format.cpp +++ b/native/jni/magiskboot/format.cpp @@ -27,10 +27,6 @@ format_t check_fmt(const void *buf, size_t len) { return CHROMEOS; } else if (MATCH(BOOT_MAGIC)) { return AOSP; - } else if (MATCH(ELF32_MAGIC)) { - return ELF32; - } else if (MATCH(ELF64_MAGIC)) { - return ELF64; } else if (MATCH(GZIP1_MAGIC) || MATCH(GZIP2_MAGIC)) { return GZIP; } else if (MATCH(LZOP_MAGIC)) { diff --git a/native/jni/magiskboot/format.h b/native/jni/magiskboot/format.h index 1d53ddb13..6ec8ab042 100644 --- a/native/jni/magiskboot/format.h +++ b/native/jni/magiskboot/format.h @@ -8,8 +8,6 @@ typedef enum { /* Boot formats */ CHROMEOS, AOSP, - ELF32, - ELF64, DHTB, BLOB, /* Compression formats */ @@ -29,8 +27,6 @@ typedef enum { #define BOOT_MAGIC "ANDROID!" #define CHROMEOS_MAGIC "CHROMEOS" -#define ELF32_MAGIC "\x7f""ELF\x01" -#define ELF64_MAGIC "\x7f""ELF\x02" #define GZIP1_MAGIC "\x1f\x8b" #define GZIP2_MAGIC "\x1f\x9e" #define LZOP_MAGIC "\x89""LZO" From 3216ef9f47784b7c02d0e4d7bf283806db8f2d89 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 23 May 2019 01:08:07 -0700 Subject: [PATCH 3/3] Upgrade AS --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 12c35b6ec..6ca2511e7 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ buildscript { } dependencies { classpath 'com.android.tools:r8:1.4.96' - classpath 'com.android.tools.build:gradle:3.5.0-beta01' + classpath 'com.android.tools.build:gradle:3.5.0-beta02' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31" diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7fe046fef..e0c5b50a3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Apr 26 14:06:46 CEST 2019 +#Thu May 23 01:06:46 PDT 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4-rc-1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip