From 726a162ac4b2b7cb0a7ac4a10733fcc4bf88477a Mon Sep 17 00:00:00 2001 From: bemerguy Date: Wed, 3 Apr 2024 01:47:56 -0300 Subject: [PATCH] throne_tracker: Fix Manager sometimes not detecting KSU and optimize it. The original logic was wrong and used 3 strlen()s for every file found. Optimize it by first comparing only the filename length, given we already know it, and then strncmp() to compare with "base.apk" Tested successfully on my Bandido Kernel (4.19) --- kernel/throne_tracker.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/throne_tracker.c b/kernel/throne_tracker.c index d18385d49c3a..90181b7eaf27 100644 --- a/kernel/throne_tracker.c +++ b/kernel/throne_tracker.c @@ -159,8 +159,7 @@ FILLDIR_RETURN_TYPE my_actor(struct dir_context *ctx, const char *name, iterate_dir(file, &sub_ctx.ctx); filp_close(file, NULL); } else { - if ((strlen(name) == strlen("base.apk")) && - (strncmp(name, "base.apk", strlen("base.apk")) == 0)) { + if ((namelen == 8) && (strncmp(name, "base.apk", namelen) == 0)) { bool is_manager = is_manager_apk(dirpath); pr_info("Found base.apk at path: %s, is_manager: %d\n", dirpath, is_manager);