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") {