From 552ec1eb354a6bd4f585293127e9ddc7dfa6a8f2 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 20 Nov 2020 22:52:09 -0800 Subject: [PATCH] Header v3 does not have name entry --- native/jni/magiskboot/bootimg.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/native/jni/magiskboot/bootimg.cpp b/native/jni/magiskboot/bootimg.cpp index 7a1047f55..c4c00d55d 100644 --- a/native/jni/magiskboot/bootimg.cpp +++ b/native/jni/magiskboot/bootimg.cpp @@ -104,7 +104,8 @@ 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()); - fprintf(fp, "name=%s\n", name()); + if (name()) + fprintf(fp, "name=%s\n", name()); fprintf(fp, "cmdline=%.*s%.*s\n", BOOT_ARGS_SIZE, cmdline(), BOOT_EXTRA_ARGS_SIZE, extra_cmdline()); uint32_t ver = os_version(); if (ver) { @@ -129,7 +130,7 @@ 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") { + } else if (key == "name" && name()) { memset(name(), 0, 16); memcpy(name(), value.data(), value.length() > 15 ? 15 : value.length()); } else if (key == "cmdline") {