fix: close client in RequestLogcatFd; fix: not closing client in error cases

This commit fixes the case where Zygiskd would close the client in "RequestLogcatFd" action, and also fixes the leak of closes for client when handling errors.
This commit is contained in:
ThePedroo
2024-10-01 20:54:58 -03:00
parent b392730366
commit 7a6ca482f0

View File

@@ -361,7 +361,7 @@ struct __attribute__((__packed__)) MsgHead {
};
void zygiskd_start(char *restrict argv[]) {
LOGI("Welcome to ReZygisk %s!\n", ZKSU_VERSION);
LOGI("Welcome to ReZygisk %s Zygiskd!\n", ZKSU_VERSION);
enum RootImpl impl = get_impl();
if (impl == None) {
@@ -574,6 +574,8 @@ void zygiskd_start(char *restrict argv[]) {
if (ret == -1) {
LOGE("Failed reading logcat tag.\n");
close(client_fd);
break;
}
@@ -585,6 +587,8 @@ void zygiskd_start(char *restrict argv[]) {
if (ret == -1) {
LOGE("Failed reading logcat message.\n");
close(client_fd);
break;
}
@@ -735,10 +739,17 @@ void zygiskd_start(char *restrict argv[]) {
ret = write_int(client_fd, 0);
ASSURE_SIZE_WRITE_BREAK("RequestCompanionSocket", "response", ret, sizeof(int));
close(module->companion);
module->companion = -1;
close(client_fd);
}
} else {
ret = write_int(client_fd, 0);
ASSURE_SIZE_WRITE_BREAK("RequestCompanionSocket", "response", ret, sizeof(int));
close(client_fd);
}
LOGI("ZD++ RequestCompanionSocket\n");
@@ -784,7 +795,7 @@ void zygiskd_start(char *restrict argv[]) {
}
}
if (action != RequestCompanionSocket) close(client_fd);
if (action != RequestCompanionSocket && action != RequestLogcatFd) close(client_fd);
continue;
}