From 52ba6d11bca116008d8df0c53ffa4942f4f5dc5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AE=8B=E9=A1=B5?= <31466456+canyie@users.noreply.github.com> Date: Sun, 7 Aug 2022 20:09:46 +0800 Subject: [PATCH] Don't let remote errors crash Zygisk Fix #6095 --- native/src/core/daemon.cpp | 6 +++--- native/src/zygisk/zygisk.hpp | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/native/src/core/daemon.cpp b/native/src/core/daemon.cpp index 0b8e2a71e..7dfc65f86 100644 --- a/native/src/core/daemon.cpp +++ b/native/src/core/daemon.cpp @@ -447,13 +447,13 @@ int connect_daemon(int req, bool create) { break; case MainResponse::ERROR: LOGE("Daemon error\n"); - exit(-1); + return -1; case MainResponse::ROOT_REQUIRED: LOGE("Root is required for this operation\n"); - exit(-1); + return -1; case MainResponse::ACCESS_DENIED: LOGE("Access denied\n"); - exit(-1); + return -1; default: __builtin_unreachable(); } diff --git a/native/src/zygisk/zygisk.hpp b/native/src/zygisk/zygisk.hpp index 3292bb4c5..56d7e9476 100644 --- a/native/src/zygisk/zygisk.hpp +++ b/native/src/zygisk/zygisk.hpp @@ -59,6 +59,7 @@ int remote_request_unmount(); inline int zygisk_request(int req) { int fd = connect_daemon(MainRequest::ZYGISK); + if (fd < 0) return fd; write_int(fd, req); return fd; }