From 9ea3169ca9db1712ed29f713af53bead6526d65e Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 20 Nov 2021 22:51:22 -0800 Subject: [PATCH] Do not allow modifying page sizes --- native/jni/magiskboot/bootimg.cpp | 5 +---- native/jni/magiskboot/bootimg.hpp | 7 ++----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/native/jni/magiskboot/bootimg.cpp b/native/jni/magiskboot/bootimg.cpp index 917a807fe..73365cbdf 100644 --- a/native/jni/magiskboot/bootimg.cpp +++ b/native/jni/magiskboot/bootimg.cpp @@ -94,7 +94,6 @@ void dyn_img_hdr::print() { void dyn_img_hdr::dump_hdr_file() { FILE *fp = xfopen(HEADER_FILE, "w"); - fprintf(fp, "pagesize=%u\n", page_size()); if (name()) fprintf(fp, "name=%s\n", name()); fprintf(fp, "cmdline=%.*s%.*s\n", BOOT_ARGS_SIZE, cmdline(), BOOT_EXTRA_ARGS_SIZE, extra_cmdline()); @@ -119,9 +118,7 @@ void dyn_img_hdr::dump_hdr_file() { void dyn_img_hdr::load_hdr_file() { parse_prop_file(HEADER_FILE, [=](string_view key, string_view value) -> bool { - if (key == "page_size") { - page_size() = parse_int(value); - } else if (key == "name" && name()) { + if (key == "name" && name()) { memset(name(), 0, 16); memcpy(name(), value.data(), value.length() > 15 ? 15 : value.length()); } else if (key == "cmdline") { diff --git a/native/jni/magiskboot/bootimg.hpp b/native/jni/magiskboot/bootimg.hpp index 1c3d8e429..6929cb91f 100644 --- a/native/jni/magiskboot/bootimg.hpp +++ b/native/jni/magiskboot/bootimg.hpp @@ -351,7 +351,7 @@ struct dyn_img_hdr { decl_var(kernel_size, 32) decl_var(ramdisk_size, 32) decl_var(second_size, 32) - decl_var(page_size, 32) + decl_val(page_size, uint32_t) decl_val(header_version, uint32_t) decl_var(extra_size, 32) decl_var(os_version, 32) @@ -489,11 +489,8 @@ struct dyn_img_v3 : public dyn_img_hdr_boot { impl_val(cmdline) // Make API compatible - uint32_t &page_size() override { page_sz = 4096; return page_sz; } + uint32_t page_size() override { return 4096; } char *extra_cmdline() override { return &v4_hdr->cmdline[BOOT_ARGS_SIZE]; } - -private: - uint32_t page_sz = 4096; }; struct dyn_img_v4 : public dyn_img_v3 {