Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
44643ad7
Commit
44643ad7
authored
Oct 31, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restrict pointer aliasing
Close #6354, close #6353
parent
1e53a555
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
14 deletions
+16
-14
files.hpp
native/src/base/files.hpp
+3
-3
files.rs
native/src/base/files.rs
+2
-3
xwrap.hpp
native/src/base/xwrap.hpp
+5
-4
xwrap.rs
native/src/base/xwrap.rs
+2
-2
entry.cpp
native/src/zygisk/entry.cpp
+4
-2
No files found.
native/src/base/files.hpp
View file @
44643ad7
...
@@ -61,8 +61,7 @@ struct mmap_data : public byte_data {
...
@@ -61,8 +61,7 @@ struct mmap_data : public byte_data {
extern
"C"
{
extern
"C"
{
int
mkdirs
(
const
char
*
path
,
mode_t
mode
);
int
mkdirs
(
const
char
*
path
,
mode_t
mode
);
ssize_t
canonical_path
(
const
char
*
path
,
char
*
buf
,
size_t
bufsiz
);
ssize_t
canonical_path
(
const
char
*
__restrict__
path
,
char
*
__restrict__
buf
,
size_t
bufsiz
);
ssize_t
read_link
(
const
char
*
pathname
,
char
*
buf
,
size_t
bufsiz
);
}
// extern "C"
}
// extern "C"
...
@@ -74,7 +73,8 @@ void mv_dir(int src, int dest);
...
@@ -74,7 +73,8 @@ void mv_dir(int src, int dest);
void
cp_afc
(
const
char
*
src
,
const
char
*
dest
);
void
cp_afc
(
const
char
*
src
,
const
char
*
dest
);
void
link_path
(
const
char
*
src
,
const
char
*
dest
);
void
link_path
(
const
char
*
src
,
const
char
*
dest
);
void
link_dir
(
int
src
,
int
dest
);
void
link_dir
(
int
src
,
int
dest
);
static
inline
ssize_t
realpath
(
const
char
*
path
,
char
*
buf
,
size_t
bufsiz
)
{
static
inline
ssize_t
realpath
(
const
char
*
__restrict__
path
,
char
*
__restrict__
buf
,
size_t
bufsiz
)
{
return
canonical_path
(
path
,
buf
,
bufsiz
);
return
canonical_path
(
path
,
buf
,
bufsiz
);
}
}
int
getattr
(
const
char
*
path
,
file_attr
*
a
);
int
getattr
(
const
char
*
path
,
file_attr
*
a
);
...
...
native/src/base/files.rs
View file @
44643ad7
...
@@ -12,8 +12,7 @@ pub mod unsafe_impl {
...
@@ -12,8 +12,7 @@ pub mod unsafe_impl {
use
crate
::
slice_from_ptr_mut
;
use
crate
::
slice_from_ptr_mut
;
#[no_mangle]
pub
unsafe
fn
readlink
(
path
:
*
const
c_char
,
buf
:
*
mut
u8
,
bufsz
:
usize
)
->
isize
{
pub
unsafe
extern
"C"
fn
read_link
(
path
:
*
const
c_char
,
buf
:
*
mut
u8
,
bufsz
:
usize
)
->
isize
{
let
r
=
libc
::
readlink
(
path
,
buf
.cast
(),
bufsz
-
1
);
let
r
=
libc
::
readlink
(
path
,
buf
.cast
(),
bufsz
-
1
);
if
r
>=
0
{
if
r
>=
0
{
*
buf
.offset
(
r
)
=
b
'\
0
'
;
*
buf
.offset
(
r
)
=
b
'\
0
'
;
...
@@ -68,7 +67,7 @@ macro_rules! xopen_fd {
...
@@ -68,7 +67,7 @@ macro_rules! xopen_fd {
}
}
pub
fn
readlink
(
path
:
&
CStr
,
data
:
&
mut
[
u8
])
->
isize
{
pub
fn
readlink
(
path
:
&
CStr
,
data
:
&
mut
[
u8
])
->
isize
{
unsafe
{
unsafe_impl
::
read
_
link
(
path
.as_ptr
(),
data
.as_mut_ptr
(),
data
.len
())
}
unsafe
{
unsafe_impl
::
readlink
(
path
.as_ptr
(),
data
.as_mut_ptr
(),
data
.len
())
}
}
}
pub
fn
fd_path
(
fd
:
RawFd
,
buf
:
&
mut
[
u8
])
->
isize
{
pub
fn
fd_path
(
fd
:
RawFd
,
buf
:
&
mut
[
u8
])
->
isize
{
...
...
native/src/base/xwrap.hpp
View file @
44643ad7
...
@@ -40,8 +40,9 @@ int xfstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
...
@@ -40,8 +40,9 @@ int xfstatat(int dirfd, const char *pathname, struct stat *buf, int flags);
int
xdup
(
int
fd
);
int
xdup
(
int
fd
);
int
xdup2
(
int
oldfd
,
int
newfd
);
int
xdup2
(
int
oldfd
,
int
newfd
);
int
xdup3
(
int
oldfd
,
int
newfd
,
int
flags
);
int
xdup3
(
int
oldfd
,
int
newfd
,
int
flags
);
ssize_t
xreadlink
(
const
char
*
pathname
,
char
*
buf
,
size_t
bufsiz
);
ssize_t
xreadlink
(
const
char
*
__restrict__
pathname
,
char
*
__restrict__
buf
,
size_t
bufsiz
);
ssize_t
xreadlinkat
(
int
dirfd
,
const
char
*
pathname
,
char
*
buf
,
size_t
bufsiz
);
ssize_t
xreadlinkat
(
int
dirfd
,
const
char
*
__restrict__
pathname
,
char
*
__restrict__
buf
,
size_t
bufsiz
);
int
xsymlink
(
const
char
*
target
,
const
char
*
linkpath
);
int
xsymlink
(
const
char
*
target
,
const
char
*
linkpath
);
int
xsymlinkat
(
const
char
*
target
,
int
newdirfd
,
const
char
*
linkpath
);
int
xsymlinkat
(
const
char
*
target
,
int
newdirfd
,
const
char
*
linkpath
);
int
xlinkat
(
int
olddirfd
,
const
char
*
oldpath
,
int
newdirfd
,
const
char
*
newpath
,
int
flags
);
int
xlinkat
(
int
olddirfd
,
const
char
*
oldpath
,
int
newdirfd
,
const
char
*
newpath
,
int
flags
);
...
@@ -58,7 +59,7 @@ void *xmmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset
...
@@ -58,7 +59,7 @@ void *xmmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset
ssize_t
xsendfile
(
int
out_fd
,
int
in_fd
,
off_t
*
offset
,
size_t
count
);
ssize_t
xsendfile
(
int
out_fd
,
int
in_fd
,
off_t
*
offset
,
size_t
count
);
pid_t
xfork
();
pid_t
xfork
();
int
xpoll
(
pollfd
*
fds
,
nfds_t
nfds
,
int
timeout
);
int
xpoll
(
pollfd
*
fds
,
nfds_t
nfds
,
int
timeout
);
ssize_t
xrealpath
(
const
char
*
path
,
char
*
buf
,
size_t
bufsiz
);
ssize_t
xrealpath
(
const
char
*
__restrict__
path
,
char
*
__restrict__
buf
,
size_t
bufsiz
);
int
xmknod
(
const
char
*
pathname
,
mode_t
mode
,
dev_t
dev
);
int
xmknod
(
const
char
*
pathname
,
mode_t
mode
,
dev_t
dev
);
}
// extern "C"
}
// extern "C"
native/src/base/xwrap.rs
View file @
44643ad7
...
@@ -16,7 +16,7 @@ mod unsafe_impl {
...
@@ -16,7 +16,7 @@ mod unsafe_impl {
use
cfg_if
::
cfg_if
;
use
cfg_if
::
cfg_if
;
use
libc
::{
c_char
,
nfds_t
,
off_t
,
pollfd
};
use
libc
::{
c_char
,
nfds_t
,
off_t
,
pollfd
};
use
crate
::
unsafe_impl
::
read
_
link
;
use
crate
::
unsafe_impl
::
readlink
;
use
crate
::{
perror
,
ptr_to_str
,
slice_from_ptr
,
slice_from_ptr_mut
};
use
crate
::{
perror
,
ptr_to_str
,
slice_from_ptr
,
slice_from_ptr_mut
};
#[no_mangle]
#[no_mangle]
...
@@ -41,7 +41,7 @@ mod unsafe_impl {
...
@@ -41,7 +41,7 @@ mod unsafe_impl {
#[no_mangle]
#[no_mangle]
pub
unsafe
extern
"C"
fn
xreadlink
(
path
:
*
const
c_char
,
buf
:
*
mut
u8
,
bufsz
:
usize
)
->
isize
{
pub
unsafe
extern
"C"
fn
xreadlink
(
path
:
*
const
c_char
,
buf
:
*
mut
u8
,
bufsz
:
usize
)
->
isize
{
let
r
=
read
_
link
(
path
,
buf
,
bufsz
);
let
r
=
readlink
(
path
,
buf
,
bufsz
);
if
r
<
0
{
if
r
<
0
{
perror!
(
"readlink"
);
perror!
(
"readlink"
);
}
}
...
...
native/src/zygisk/entry.cpp
View file @
44643ad7
...
@@ -161,8 +161,10 @@ static vector<int> get_module_fds(bool is_64_bit) {
...
@@ -161,8 +161,10 @@ static vector<int> get_module_fds(bool is_64_bit) {
}
}
static
bool
get_exe
(
int
pid
,
char
*
buf
,
size_t
sz
)
{
static
bool
get_exe
(
int
pid
,
char
*
buf
,
size_t
sz
)
{
ssprintf
(
buf
,
sz
,
"/proc/%d/exe"
,
pid
);
char
exe
[
128
];
return
xreadlink
(
buf
,
buf
,
sz
)
>
0
;
if
(
ssprintf
(
exe
,
sizeof
(
exe
),
"/proc/%d/exe"
,
pid
)
<
0
)
return
false
;
return
xreadlink
(
exe
,
buf
,
sz
)
>
0
;
}
}
static
pthread_mutex_t
zygiskd_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
pthread_mutex_t
zygiskd_lock
=
PTHREAD_MUTEX_INITIALIZER
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment