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
93ef90cd
Commit
93ef90cd
authored
Apr 11, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix FORTIFY crashes
parent
e165a1e6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
file.cpp
native/jni/utils/file.cpp
+3
-3
xwrap.cpp
native/jni/utils/xwrap.cpp
+16
-0
xwrap.hpp
native/jni/utils/xwrap.hpp
+2
-0
No files found.
native/jni/utils/file.cpp
View file @
93ef90cd
...
...
@@ -127,7 +127,7 @@ void cp_afc(const char *src, const char *dest) {
unlink
(
dest
);
if
(
S_ISREG
(
a
.
st
.
st_mode
))
{
int
sfd
=
xopen
(
src
,
O_RDONLY
|
O_CLOEXEC
);
int
dfd
=
xopen
(
dest
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_CLOEXEC
);
int
dfd
=
xopen
(
dest
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_CLOEXEC
,
0
);
xsendfile
(
dfd
,
sfd
,
nullptr
,
a
.
st
.
st_size
);
close
(
sfd
);
close
(
dfd
);
...
...
@@ -158,7 +158,7 @@ void clone_dir(int src, int dest) {
}
case
DT_REG
:
{
int
sfd
=
xopenat
(
src
,
entry
->
d_name
,
O_RDONLY
|
O_CLOEXEC
);
int
dfd
=
xopenat
(
dest
,
entry
->
d_name
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_CLOEXEC
);
int
dfd
=
xopenat
(
dest
,
entry
->
d_name
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
|
O_CLOEXEC
,
0
);
xsendfile
(
dfd
,
sfd
,
nullptr
,
a
.
st
.
st_size
);
fsetattr
(
dfd
,
&
a
);
close
(
dfd
);
...
...
@@ -359,7 +359,7 @@ void parse_mnt(const char *file, const function<bool(mntent*)> &fn) {
void
backup_folder
(
const
char
*
dir
,
vector
<
raw_file
>
&
files
)
{
char
path
[
4096
];
realpath
(
dir
,
path
);
x
realpath
(
dir
,
path
);
int
len
=
strlen
(
path
);
post_order_walk
(
xopen
(
dir
,
O_RDONLY
),
[
&
](
int
dfd
,
dirent
*
entry
)
->
int
{
int
fd
=
xopenat
(
dfd
,
entry
->
d_name
,
O_RDONLY
);
...
...
native/jni/utils/xwrap.cpp
View file @
93ef90cd
...
...
@@ -53,6 +53,14 @@ int xopenat(int dirfd, const char *pathname, int flags) {
return
fd
;
}
int
xopenat
(
int
dirfd
,
const
char
*
pathname
,
int
flags
,
mode_t
mode
)
{
int
fd
=
openat
(
dirfd
,
pathname
,
flags
,
mode
);
if
(
fd
<
0
)
{
PLOGE
(
"openat: %s"
,
pathname
);
}
return
fd
;
}
ssize_t
xwrite
(
int
fd
,
const
void
*
buf
,
size_t
count
)
{
int
ret
=
write
(
fd
,
buf
,
count
);
if
(
count
!=
ret
)
{
...
...
@@ -435,3 +443,11 @@ int xinotify_init1(int flags) {
}
return
ret
;
}
char
*
xrealpath
(
const
char
*
path
,
char
*
resolved_path
)
{
char
*
ret
=
realpath
(
path
,
resolved_path
);
if
(
ret
==
nullptr
)
{
PLOGE
(
"xrealpath"
);
}
return
ret
;
}
native/jni/utils/xwrap.hpp
View file @
93ef90cd
...
...
@@ -10,6 +10,7 @@ FILE *xfdopen(int fd, const char *mode);
int
xopen
(
const
char
*
pathname
,
int
flags
);
int
xopen
(
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
int
xopenat
(
int
dirfd
,
const
char
*
pathname
,
int
flags
);
int
xopenat
(
int
dirfd
,
const
char
*
pathname
,
int
flags
,
mode_t
mode
);
ssize_t
xwrite
(
int
fd
,
const
void
*
buf
,
size_t
count
);
ssize_t
xread
(
int
fd
,
void
*
buf
,
size_t
count
);
ssize_t
xxread
(
int
fd
,
void
*
buf
,
size_t
count
);
...
...
@@ -57,4 +58,5 @@ ssize_t xsendfile(int out_fd, int in_fd, off_t *offset, size_t count);
pid_t
xfork
();
int
xpoll
(
struct
pollfd
*
fds
,
nfds_t
nfds
,
int
timeout
);
int
xinotify_init1
(
int
flags
);
char
*
xrealpath
(
const
char
*
path
,
char
*
resolved_path
);
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