magiskboot: accept forcing recognized but unsupported format compression
- when input image had a different supported format (e.g. gzip) magiskboot would not accept a manually compressed ramdisk or kernel in an unsupported format (e.g. lzop) despite being able to recognize it, so instead would double compress using whatever the input format was, breaking the image with, in effect, a ramdisk.cpio.lzo.gz
This commit is contained in:
parent
8513946e09
commit
f341f3b2dd
@ -419,7 +419,7 @@ void repack(const char* orig_image, const char* out_image) {
|
|||||||
size_t raw_size;
|
size_t raw_size;
|
||||||
void *raw_buf;
|
void *raw_buf;
|
||||||
mmap_ro(KERNEL_FILE, raw_buf, raw_size);
|
mmap_ro(KERNEL_FILE, raw_buf, raw_size);
|
||||||
if (!COMPRESSED(check_fmt(raw_buf, raw_size)) && COMPRESSED(boot.k_fmt)) {
|
if (!COMPRESSED_ANY(check_fmt(raw_buf, raw_size)) && COMPRESSED(boot.k_fmt)) {
|
||||||
boot.hdr->kernel_size = compress(boot.k_fmt, fd, raw_buf, raw_size);
|
boot.hdr->kernel_size = compress(boot.k_fmt, fd, raw_buf, raw_size);
|
||||||
} else {
|
} else {
|
||||||
boot.hdr->kernel_size = write(fd, raw_buf, raw_size);
|
boot.hdr->kernel_size = write(fd, raw_buf, raw_size);
|
||||||
@ -442,7 +442,7 @@ void repack(const char* orig_image, const char* out_image) {
|
|||||||
size_t raw_size;
|
size_t raw_size;
|
||||||
void *raw_buf;
|
void *raw_buf;
|
||||||
mmap_ro(RAMDISK_FILE, raw_buf, raw_size);
|
mmap_ro(RAMDISK_FILE, raw_buf, raw_size);
|
||||||
if (!COMPRESSED(check_fmt(raw_buf, raw_size)) && COMPRESSED(boot.r_fmt)) {
|
if (!COMPRESSED_ANY(check_fmt(raw_buf, raw_size)) && COMPRESSED(boot.r_fmt)) {
|
||||||
boot.hdr->ramdisk_size = compress(boot.r_fmt, fd, raw_buf, raw_size);
|
boot.hdr->ramdisk_size = compress(boot.r_fmt, fd, raw_buf, raw_size);
|
||||||
} else {
|
} else {
|
||||||
boot.hdr->ramdisk_size = write(fd, raw_buf, raw_size);
|
boot.hdr->ramdisk_size = write(fd, raw_buf, raw_size);
|
||||||
|
@ -25,6 +25,7 @@ typedef enum {
|
|||||||
} format_t;
|
} format_t;
|
||||||
|
|
||||||
#define COMPRESSED(fmt) ((fmt) >= GZIP && (fmt) <= LZ4_LEGACY)
|
#define COMPRESSED(fmt) ((fmt) >= GZIP && (fmt) <= LZ4_LEGACY)
|
||||||
|
#define COMPRESSED_ANY(fmt) ((fmt) >= GZIP && (fmt) <= LZOP)
|
||||||
|
|
||||||
#define BOOT_MAGIC "ANDROID!"
|
#define BOOT_MAGIC "ANDROID!"
|
||||||
#define CHROMEOS_MAGIC "CHROMEOS"
|
#define CHROMEOS_MAGIC "CHROMEOS"
|
||||||
|
Loading…
Reference in New Issue
Block a user