mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-22 21:41:41 +00:00
Only dlopen valid fd
This commit is contained in:
parent
3f660a3963
commit
9e8218089b
@ -359,6 +359,11 @@ void HookContext::run_modules_pre(const vector<int> &fds) {
|
|||||||
modules.reserve(fds.size());
|
modules.reserve(fds.size());
|
||||||
|
|
||||||
for (int i = 0; i < fds.size(); ++i) {
|
for (int i = 0; i < fds.size(); ++i) {
|
||||||
|
struct stat s{};
|
||||||
|
if (fstat(fds[i], &s) != 0 || !S_ISREG(s.st_mode)) {
|
||||||
|
close(fds[i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
android_dlextinfo info {
|
android_dlextinfo info {
|
||||||
.flags = ANDROID_DLEXT_USE_LIBRARY_FD,
|
.flags = ANDROID_DLEXT_USE_LIBRARY_FD,
|
||||||
.library_fd = fds[i],
|
.library_fd = fds[i],
|
||||||
|
@ -114,6 +114,8 @@ static void zygiskd(int socket) {
|
|||||||
vector<int> module_fds = recv_fds(socket);
|
vector<int> module_fds = recv_fds(socket);
|
||||||
for (int fd : module_fds) {
|
for (int fd : module_fds) {
|
||||||
comp_entry entry = nullptr;
|
comp_entry entry = nullptr;
|
||||||
|
struct stat s{};
|
||||||
|
if (fstat(fd, &s) == 0 && S_ISREG(s.st_mode)) {
|
||||||
android_dlextinfo info {
|
android_dlextinfo info {
|
||||||
.flags = ANDROID_DLEXT_USE_LIBRARY_FD,
|
.flags = ANDROID_DLEXT_USE_LIBRARY_FD,
|
||||||
.library_fd = fd,
|
.library_fd = fd,
|
||||||
@ -123,6 +125,7 @@ static void zygiskd(int socket) {
|
|||||||
} else {
|
} else {
|
||||||
LOGW("Failed to dlopen zygisk module: %s\n", dlerror());
|
LOGW("Failed to dlopen zygisk module: %s\n", dlerror());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
modules.push_back(entry);
|
modules.push_back(entry);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user