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
e0b56450
Commit
e0b56450
authored
Mar 03, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Directly use getrandom system call if possible"
This reverts commit
e7c82f20
. Fix #5516
parent
e51aacb0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
misc.cpp
native/jni/utils/misc.cpp
+8
-12
No files found.
native/jni/utils/misc.cpp
View file @
e0b56450
...
@@ -35,21 +35,17 @@ int fork_no_orphan() {
...
@@ -35,21 +35,17 @@ int fork_no_orphan() {
int
gen_rand_str
(
char
*
buf
,
int
len
,
bool
varlen
)
{
int
gen_rand_str
(
char
*
buf
,
int
len
,
bool
varlen
)
{
constexpr
char
ALPHANUM
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
;
constexpr
char
ALPHANUM
[]
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
;
static
mt19937
gen
([]{
static
std
::
mt19937
gen
([]{
mt19937
::
result_type
seed
;
if
(
access
(
"/dev/urandom"
,
F_OK
)
!=
0
)
if
(
syscall
(
__NR_getrandom
,
&
seed
,
sizeof
(
seed
),
0
)
<
0
)
{
mknod
(
"/dev/urandom"
,
0600
|
S_IFCHR
,
makedev
(
1
,
9
));
// This can happen if device is running a too low Linux version
int
fd
=
xopen
(
"/dev/urandom"
,
O_RDONLY
|
O_CLOEXEC
);
if
(
access
(
"/dev/urandom"
,
F_OK
)
!=
0
)
unsigned
seed
;
mknod
(
"/dev/urandom"
,
0600
|
S_IFCHR
,
makedev
(
1
,
9
));
xxread
(
fd
,
&
seed
,
sizeof
(
seed
));
int
fd
=
xopen
(
"/dev/urandom"
,
O_RDONLY
|
O_CLOEXEC
);
xxread
(
fd
,
&
seed
,
sizeof
(
seed
));
close
(
fd
);
}
return
seed
;
return
seed
;
}());
}());
uniform_int_distribution
<
int
>
dist
(
0
,
sizeof
(
ALPHANUM
)
-
2
);
std
::
uniform_int_distribution
<
int
>
dist
(
0
,
sizeof
(
ALPHANUM
)
-
2
);
if
(
varlen
)
{
if
(
varlen
)
{
uniform_int_distribution
<
int
>
len_dist
(
len
/
2
,
len
);
std
::
uniform_int_distribution
<
int
>
len_dist
(
len
/
2
,
len
);
len
=
len_dist
(
gen
);
len
=
len_dist
(
gen
);
}
}
for
(
int
i
=
0
;
i
<
len
-
1
;
++
i
)
for
(
int
i
=
0
;
i
<
len
-
1
;
++
i
)
...
...
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