Minor bug fixes

This commit is contained in:
topjohnwu 2021-08-22 02:11:48 -07:00
parent 171d68ca72
commit b591af7803
2 changed files with 6 additions and 6 deletions

View File

@ -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) {

View File

@ -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 {