From 182c0293ca0dd9bd6d093dc19fc5725a2bdd4b06 Mon Sep 17 00:00:00 2001 From: ThePedroo Date: Mon, 7 Oct 2024 00:00:33 -0300 Subject: [PATCH] fix: compiling errors This commit fixes compiling errors from missing declaration of variables and missing macros. --- zygiskd/src/companion.c | 4 ++-- zygiskd/src/utils.h | 42 +++++++++++++++++++++++++++++++++++++++ zygiskd/src/zygiskd.c | 44 +---------------------------------------- 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/zygiskd/src/companion.c b/zygiskd/src/companion.c index c6df404..5d4edc7 100644 --- a/zygiskd/src/companion.c +++ b/zygiskd/src/companion.c @@ -103,7 +103,7 @@ void entry(int fd) { break; } - int fd = read_fd(fd); + int client_fd = read_fd(fd); if (fd == -1) { LOGE("Failed to receive client fd\n"); @@ -117,7 +117,7 @@ void entry(int fd) { exit(0); } - args->fd = fd; + args->fd = client_fd; args->entry = module_entry; LOGI("New companion request.\n - Module name: %.*s\n - Client fd: %d\n", (int)ret, name, args->fd); diff --git a/zygiskd/src/utils.h b/zygiskd/src/utils.h index cf273e0..e5dac56 100644 --- a/zygiskd/src/utils.h +++ b/zygiskd/src/utils.h @@ -16,6 +16,48 @@ __android_log_print(ANDROID_LOG_ERROR , lp_select("zygiskd32", "zygiskd64"), __VA_ARGS__); \ printf(__VA_ARGS__); +#define ASSURE_SIZE_WRITE(area_name, subarea_name, sent_size, expected_size) \ + if (sent_size != (ssize_t)(expected_size)) { \ + LOGE("Failed to sent " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ + \ + return; \ + } + +#define ASSURE_SIZE_READ(area_name, subarea_name, sent_size, expected_size) \ + if (sent_size != (ssize_t)(expected_size)) { \ + LOGE("Failed to read " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ + \ + return; \ + } + +#define ASSURE_SIZE_WRITE_BREAK(area_name, subarea_name, sent_size, expected_size) \ + if (sent_size != (ssize_t)(expected_size)) { \ + LOGE("Failed to sent " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ + \ + break; \ + } + +#define ASSURE_SIZE_READ_BREAK(area_name, subarea_name, sent_size, expected_size) \ + if (sent_size != (ssize_t)(expected_size)) { \ + LOGE("Failed to read " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ + \ + break; \ + } + +#define ASSURE_SIZE_WRITE_WR(area_name, subarea_name, sent_size, expected_size) \ + if (sent_size != (ssize_t)(expected_size)) { \ + LOGE("Failed to sent " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ + \ + return -1; \ + } + +#define ASSURE_SIZE_READ_WR(area_name, subarea_name, sent_size, expected_size) \ + if (sent_size != (ssize_t)(expected_size)) { \ + LOGE("Failed to read " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ + \ + return -1; \ + } + #define write_func_def(type) \ ssize_t write_## type(int fd, type val) diff --git a/zygiskd/src/zygiskd.c b/zygiskd/src/zygiskd.c index 8c4a683..364e23f 100644 --- a/zygiskd/src/zygiskd.c +++ b/zygiskd/src/zygiskd.c @@ -47,48 +47,6 @@ enum Architecture { #define ZYGISKD_FILE PATH_MODULES_DIR "/zygisksu/bin/zygiskd" lp_select("32", "64") #define ZYGISKD_PATH "/data/adb/modules/zygisksu/bin/zygiskd" lp_select("32", "64") -#define ASSURE_SIZE_WRITE(area_name, subarea_name, sent_size, expected_size) \ - if (sent_size != (ssize_t)(expected_size)) { \ - LOGE("Failed to sent " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ - \ - return; \ - } - -#define ASSURE_SIZE_READ(area_name, subarea_name, sent_size, expected_size) \ - if (sent_size != (ssize_t)(expected_size)) { \ - LOGE("Failed to read " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ - \ - return; \ - } - -#define ASSURE_SIZE_WRITE_BREAK(area_name, subarea_name, sent_size, expected_size) \ - if (sent_size != (ssize_t)(expected_size)) { \ - LOGE("Failed to sent " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ - \ - break; \ - } - -#define ASSURE_SIZE_READ_BREAK(area_name, subarea_name, sent_size, expected_size) \ - if (sent_size != (ssize_t)(expected_size)) { \ - LOGE("Failed to read " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ - \ - break; \ - } - -#define ASSURE_SIZE_WRITE_WR(area_name, subarea_name, sent_size, expected_size) \ - if (sent_size != (ssize_t)(expected_size)) { \ - LOGE("Failed to sent " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ - \ - return -1; \ - } - -#define ASSURE_SIZE_READ_WR(area_name, subarea_name, sent_size, expected_size) \ - if (sent_size != (ssize_t)(expected_size)) { \ - LOGE("Failed to read " subarea_name " in " area_name ": Expected %zu, got %zd\n", expected_size, sent_size); \ - \ - return -1; \ - } - static enum Architecture get_arch(void) { char system_arch[32]; get_property("ro.product.cpu.abi", system_arch); @@ -785,7 +743,7 @@ void zygiskd_start(char *restrict argv[]) { } case GetModuleDir: { size_t index = 0; - read_size_t(client_fd, &index); + ssize_t ret = read_size_t(client_fd, &index); ASSURE_SIZE_READ_BREAK("GetModuleDir", "index", ret, sizeof(index)); char module_dir[PATH_MAX];