Use proper socket address length
This commit is contained in:
parent
af7c6f9fce
commit
2fba3f213b
@ -113,7 +113,7 @@ void main_daemon() {
|
|||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
fd = setup_socket(&sun, MAIN_DAEMON);
|
fd = setup_socket(&sun, MAIN_DAEMON);
|
||||||
|
|
||||||
if (xbind(fd, (struct sockaddr*) &sun, sizeof(sun)))
|
if (xbind(fd, (struct sockaddr*) &sun, sizeof(sun.sun_family) + strlen(sun.sun_path + 1) + 1))
|
||||||
exit(1);
|
exit(1);
|
||||||
xlisten(fd, 10);
|
xlisten(fd, 10);
|
||||||
LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") daemon started\n");
|
LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") daemon started\n");
|
||||||
@ -149,7 +149,8 @@ void main_daemon() {
|
|||||||
int connect_daemon2(daemon_t d, int *sockfd) {
|
int connect_daemon2(daemon_t d, int *sockfd) {
|
||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
*sockfd = setup_socket(&sun, d);
|
*sockfd = setup_socket(&sun, d);
|
||||||
if (connect(*sockfd, (struct sockaddr*) &sun, sizeof(sun))) {
|
socklen_t len = sizeof(sun.sun_family) + strlen(sun.sun_path + 1) + 1;
|
||||||
|
if (connect(*sockfd, (struct sockaddr*) &sun, len)) {
|
||||||
if (getuid() != UID_ROOT || getgid() != UID_ROOT) {
|
if (getuid() != UID_ROOT || getgid() != UID_ROOT) {
|
||||||
fprintf(stderr, "No daemon is currently running!\n");
|
fprintf(stderr, "No daemon is currently running!\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -168,7 +169,7 @@ int connect_daemon2(daemon_t d, int *sockfd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (connect(*sockfd, (struct sockaddr*) &sun, sizeof(sun)))
|
while (connect(*sockfd, (struct sockaddr*) &sun, len))
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ void log_daemon() {
|
|||||||
setsid();
|
setsid();
|
||||||
struct sockaddr_un sun;
|
struct sockaddr_un sun;
|
||||||
sockfd = setup_socket(&sun, LOG_DAEMON);
|
sockfd = setup_socket(&sun, LOG_DAEMON);
|
||||||
if (xbind(sockfd, (struct sockaddr*) &sun, sizeof(sun)))
|
if (xbind(sockfd, (struct sockaddr*) &sun, sizeof(sun.sun_family) + strlen(sun.sun_path + 1) + 1))
|
||||||
exit(1);
|
exit(1);
|
||||||
xlisten(sockfd, 10);
|
xlisten(sockfd, 10);
|
||||||
LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") logger started\n");
|
LOGI("Magisk v" xstr(MAGISK_VERSION) "(" xstr(MAGISK_VER_CODE) ") logger started\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user