mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-12 06:28:29 +00:00
Use rust::String::c_str to ensure nil termination
This commit is contained in:
parent
e3e4202954
commit
9684a35cab
@ -98,9 +98,9 @@ pub mod ffi {
|
|||||||
fn patch_ro_root(self: &mut MagiskInit);
|
fn patch_ro_root(self: &mut MagiskInit);
|
||||||
|
|
||||||
// Used in C++
|
// Used in C++
|
||||||
unsafe fn setup_tmp(self: &MagiskInit, path: *const c_char);
|
unsafe fn setup_tmp(self: &mut MagiskInit, path: *const c_char);
|
||||||
fn collect_devices(self: &MagiskInit);
|
fn collect_devices(self: &MagiskInit);
|
||||||
fn mount_preinit_dir(self: &MagiskInit);
|
fn mount_preinit_dir(self: &mut MagiskInit);
|
||||||
unsafe fn find_block(self: &MagiskInit, partname: *const c_char) -> u64;
|
unsafe fn find_block(self: &MagiskInit, partname: *const c_char) -> u64;
|
||||||
unsafe fn patch_fissiond(self: &mut MagiskInit, tmp_path: *const c_char);
|
unsafe fn patch_fissiond(self: &mut MagiskInit, tmp_path: *const c_char);
|
||||||
}
|
}
|
||||||
|
@ -103,11 +103,11 @@ uint64_t MagiskInit::find_block(const char *partname) const noexcept {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagiskInit::mount_preinit_dir() const noexcept {
|
void MagiskInit::mount_preinit_dir() noexcept {
|
||||||
if (preinit_dev.empty()) return;
|
if (preinit_dev.empty()) return;
|
||||||
auto dev = find_block(preinit_dev.data());
|
auto dev = find_block(preinit_dev.c_str());
|
||||||
if (dev == 0) {
|
if (dev == 0) {
|
||||||
LOGE("Cannot find preinit %s, abort!\n", preinit_dev.data());
|
LOGE("Cannot find preinit %s, abort!\n", preinit_dev.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
xmknod(PREINITDEV, S_IFBLK | 0600, dev);
|
xmknod(PREINITDEV, S_IFBLK | 0600, dev);
|
||||||
@ -138,7 +138,7 @@ void MagiskInit::mount_preinit_dir() const noexcept {
|
|||||||
}
|
}
|
||||||
xumount2(MIRRDIR, MNT_DETACH);
|
xumount2(MIRRDIR, MNT_DETACH);
|
||||||
} else {
|
} else {
|
||||||
PLOGE("Failed to mount preinit %s\n", preinit_dev.data());
|
PLOGE("Failed to mount preinit %s\n", preinit_dev.c_str());
|
||||||
unlink(PREINITDEV);
|
unlink(PREINITDEV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ mount_root:
|
|||||||
return is_two_stage;
|
return is_two_stage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MagiskInit::setup_tmp(const char *path) const noexcept {
|
void MagiskInit::setup_tmp(const char *path) noexcept {
|
||||||
LOGD("Setup Magisk tmp at %s\n", path);
|
LOGD("Setup Magisk tmp at %s\n", path);
|
||||||
chdir("/data");
|
chdir("/data");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user