Skip to content

Commit 74d0021

Browse files
committed
Fix join path
path start with / will clean path
1 parent d52f472 commit 74d0021

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

native/src/init/rootdir.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::fs::File;
1111
use std::io::{BufReader, Read, Write};
1212
use std::os::fd::AsRawFd;
1313

14-
const ISOLATED_PATH: &str = concatcp!("/", INTERNAL_DIR, "/isolated");
14+
const ISOLATED_PATH: &str = concatcp!(INTERNAL_DIR, "/isolated");
1515

1616
fn inject_magisk_rc(file: &mut File, tmp_dir: &Utf8CStr) {
1717
debug!("Injecting magisk rc");
@@ -62,7 +62,9 @@ impl MagiskInit {
6262
let dest_path = if writable {
6363
cstr::buf::dynamic(256).join_path(src_path)
6464
} else {
65-
let path = cstr::buf::dynamic(256).join_path(ROOTOVL).join_path(src_path);
65+
let path = cstr::buf::dynamic(256)
66+
.join_path(ROOTOVL)
67+
.join_path(src_path.as_str().trim_start_matches('/'));
6668
if path.mkdirs(0o755).is_err() {
6769
return false;
6870
}
@@ -196,11 +198,11 @@ impl MagiskInit {
196198
}
197199
}
198200

199-
let dir = cstr::buf::dynamic(256).join_path(ROOTOVL).join_path("/system/bin");
201+
let dir = cstr::buf::dynamic(256).join_path(ROOTOVL).join_path("system/bin");
200202
dir.mkdirs(0o755).log_ok();
201203
let out = cstr::buf::dynamic(256)
202204
.join_path(ROOTOVL)
203-
.join_path("/system/bin/fissiond");
205+
.join_path("system/bin/fissiond");
204206
if let Ok(mut target) = out.create(
205207
OFlag::O_WRONLY | OFlag::O_CREAT | OFlag::O_TRUNC | OFlag::O_CLOEXEC,
206208
0,
@@ -234,7 +236,7 @@ impl MagiskInit {
234236

235237
let target = cstr::buf::dynamic(256)
236238
.join_path("/dev/cells/cell2")
237-
.join_path(tmp_path);
239+
.join_path(tmp_path.as_str().trim_start_matches('/'));
238240
target.mkdirs(0).log_ok();
239241
tmp_path.bind_mount_to(&target, true).log_ok();
240242
self.mount_overlay(cstr!("/dev/cells/cell2"));

0 commit comments

Comments
 (0)