From 2cdbcc566639789dc3e34c44d1df627adc02a2ea Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sat, 3 Jun 2017 05:08:52 +0800 Subject: [PATCH] Add more checks for other patches --- jni/magiskboot/cpio.c | 14 ++++++++------ jni/magiskboot/unpack.c | 2 -- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/jni/magiskboot/cpio.c b/jni/magiskboot/cpio.c index 2d0edb2f0..6765e9b8c 100644 --- a/jni/magiskboot/cpio.c +++ b/jni/magiskboot/cpio.c @@ -193,18 +193,20 @@ static void cpio_add(mode_t mode, const char *entry, const char *filename, struc static void cpio_test(struct vector *v) { #define MAGISK_PATCH 0x1 - #define SUPERSU_PATCH 0x2 + #define OTHER_PATCH 0x2 int ret = 0; cpio_file *f; + const char *OTHER_LIST[] = { "sbin/launch_daemonsu.sh", "sbin/su", "init.xposed.rc", "init.supersu.rc", NULL }; vec_for_each(v, f) { - if (strcmp(f->filename, "sbin/launch_daemonsu.sh") == 0) { - ret |= SUPERSU_PATCH; - } else if (strcmp(f->filename, "init.magisk.rc") == 0) { - ret |= MAGISK_PATCH; + for (int i = 0; OTHER_LIST[i]; ++i) { + if (strcmp(f->filename, OTHER_LIST[i]) == 0) + ret |= OTHER_PATCH; } + if (strcmp(f->filename, "init.magisk.rc") == 0) + ret |= OTHER_PATCH; } cpio_vec_destroy(v); - exit((ret & SUPERSU_PATCH) ? SUPERSU_PATCH : (ret & MAGISK_PATCH)); + exit((ret & OTHER_PATCH) ? OTHER_PATCH : (ret & MAGISK_PATCH)); } static int check_verity_pattern(const char *s) { diff --git a/jni/magiskboot/unpack.c b/jni/magiskboot/unpack.c index d5b533cb9..68e2376ca 100644 --- a/jni/magiskboot/unpack.c +++ b/jni/magiskboot/unpack.c @@ -15,8 +15,6 @@ void unpack(const char* image) { printf("Parsing boot image: [%s]\n\n", image); parse_img(orig, size); - char name[PATH_MAX]; - // Dump kernel if (mtk_kernel) { kernel += 512;