Commit 49abfcaf authored by LoveSy's avatar LoveSy Committed by topjohnwu

Fix nullptr dereference when env abnormal

parent 50710c72
...@@ -574,34 +574,35 @@ void magic_mount() { ...@@ -574,34 +574,35 @@ void magic_mount() {
char buf[4096]; char buf[4096];
LOGI("* Loading modules\n"); LOGI("* Loading modules\n");
for (const auto &m : *modules) { if (modules) {
const char *module = m.name.data(); for (const auto &m : *modules) {
char *b = buf + sprintf(buf, "%s/" MODULEMNT "/%s/", MAGISKTMP.data(), module); const char *module = m.name.data();
char *b = buf + sprintf(buf, "%s/" MODULEMNT "/%s/", MAGISKTMP.data(), module);
// Read props
strcpy(b, "system.prop"); // Read props
if (access(buf, F_OK) == 0) { strcpy(b, "system.prop");
LOGI("%s: loading [system.prop]\n", module); if (access(buf, F_OK) == 0) {
load_prop_file(buf, false); LOGI("%s: loading [system.prop]\n", module);
} load_prop_file(buf, false);
}
// Check whether skip mounting // Check whether skip mounting
strcpy(b, "skip_mount"); strcpy(b, "skip_mount");
if (access(buf, F_OK) == 0) if (access(buf, F_OK) == 0)
continue; continue;
// Double check whether the system folder exists // Double check whether the system folder exists
strcpy(b, "system"); strcpy(b, "system");
if (access(buf, F_OK) != 0) if (access(buf, F_OK) != 0)
continue; continue;
LOGI("%s: loading mount files\n", module); LOGI("%s: loading mount files\n", module);
b[-1] = '\0'; b[-1] = '\0';
int fd = xopen(buf, O_RDONLY | O_CLOEXEC); int fd = xopen(buf, O_RDONLY | O_CLOEXEC);
system->collect_files(module, fd); system->collect_files(module, fd);
close(fd); close(fd);
}
} }
if (MAGISKTMP != "/sbin") { if (MAGISKTMP != "/sbin") {
// Need to inject our binaries into /system/bin // Need to inject our binaries into /system/bin
inject_magisk_bins(system); inject_magisk_bins(system);
......
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