Skip to content

Commit 7a6ca48

Browse files
committed
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.
1 parent b392730 commit 7a6ca48

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

zygiskd/src/zygiskd.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ struct __attribute__((__packed__)) MsgHead {
361361
};
362362

363363
void zygiskd_start(char *restrict argv[]) {
364-
LOGI("Welcome to ReZygisk %s!\n", ZKSU_VERSION);
364+
LOGI("Welcome to ReZygisk %s Zygiskd!\n", ZKSU_VERSION);
365365

366366
enum RootImpl impl = get_impl();
367367
if (impl == None) {
@@ -574,6 +574,8 @@ void zygiskd_start(char *restrict argv[]) {
574574
if (ret == -1) {
575575
LOGE("Failed reading logcat tag.\n");
576576

577+
close(client_fd);
578+
577579
break;
578580
}
579581

@@ -585,6 +587,8 @@ void zygiskd_start(char *restrict argv[]) {
585587
if (ret == -1) {
586588
LOGE("Failed reading logcat message.\n");
587589

590+
close(client_fd);
591+
588592
break;
589593
}
590594

@@ -735,10 +739,17 @@ void zygiskd_start(char *restrict argv[]) {
735739

736740
ret = write_int(client_fd, 0);
737741
ASSURE_SIZE_WRITE_BREAK("RequestCompanionSocket", "response", ret, sizeof(int));
742+
743+
close(module->companion);
744+
module->companion = -1;
745+
746+
close(client_fd);
738747
}
739748
} else {
740749
ret = write_int(client_fd, 0);
741750
ASSURE_SIZE_WRITE_BREAK("RequestCompanionSocket", "response", ret, sizeof(int));
751+
752+
close(client_fd);
742753
}
743754

744755
LOGI("ZD++ RequestCompanionSocket\n");
@@ -784,7 +795,7 @@ void zygiskd_start(char *restrict argv[]) {
784795
}
785796
}
786797

787-
if (action != RequestCompanionSocket) close(client_fd);
798+
if (action != RequestCompanionSocket && action != RequestLogcatFd) close(client_fd);
788799

789800
continue;
790801
}

0 commit comments

Comments
 (0)