Commit b591af78 authored by topjohnwu's avatar topjohnwu

Minor bug fixes

parent 171d68ca
......@@ -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) {
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment