diff --git a/native/jni/core/daemon.cpp b/native/jni/core/daemon.cpp index 549d3ab3d..0497151d3 100644 --- a/native/jni/core/daemon.cpp +++ b/native/jni/core/daemon.cpp @@ -264,7 +264,7 @@ int connect_daemon(bool create) { if (connect(fd, (sockaddr*) &sun, len)) { if (!create || getuid() != UID_ROOT) { LOGE("No daemon is currently running!\n"); - return 1; + return -1; } if (fork_dont_care() == 0) { diff --git a/native/jni/zygisk/entry.cpp b/native/jni/zygisk/entry.cpp index 3b606a4bf..bc88a6182 100644 --- a/native/jni/zygisk/entry.cpp +++ b/native/jni/zygisk/entry.cpp @@ -236,11 +236,11 @@ int remote_request_unmount() { // The following code runs in magiskd static void setup_files(int client, ucred *cred) { - LOGD("zygisk: setup files\n"); + LOGD("zygisk: setup files for pid=[%d]\n", cred->pid); - char buf[PATH_MAX]; - sprintf(buf, "/proc/%d/exe", cred->pid); - if (realpath(buf, buf) == nullptr) { + char buf[256]; + snprintf(buf, sizeof(buf), "/proc/%d/exe", cred->pid); + if (xreadlink(buf, buf, sizeof(buf)) < 0) { write_int(client, 1); return; } @@ -276,7 +276,7 @@ static void do_unmount(int client, ucred *cred) { static void send_log_pipe(int fd) { // There is race condition here, but we can't really do much about it... - if (logd_fd) { + if (logd_fd >= 0) { write_int(fd, 0); send_fd(fd, logd_fd); } else {