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
48df6b84
Commit
48df6b84
authored
Oct 31, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use memmem instead of strstr
It might not be null terminated
parent
ae23ae2d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
dtb.cpp
native/jni/magiskboot/dtb.cpp
+4
-6
No files found.
native/jni/magiskboot/dtb.cpp
View file @
48df6b84
#include <bitset>
#include <bitset>
#include <vector>
#include <vector>
#include <map>
#include <map>
#include <libfdt.h>
#include <utils.hpp>
#include <utils.hpp>
#include "magiskboot.hpp"
#include "magiskboot.hpp"
#include "dtb.hpp"
#include "dtb.hpp"
#include "format.hpp"
#include "format.hpp"
extern
"C"
{
#include <libfdt.h>
}
using
namespace
std
;
using
namespace
std
;
...
@@ -147,14 +145,14 @@ static bool dtb_patch(const char *file) {
...
@@ -147,14 +145,14 @@ static bool dtb_patch(const char *file) {
if
(
fdt_get_name
(
fdt
,
node
,
nullptr
)
!=
"chosen"
sv
)
if
(
fdt_get_name
(
fdt
,
node
,
nullptr
)
!=
"chosen"
sv
)
continue
;
continue
;
int
len
;
int
len
;
if
(
char
*
value
=
(
char
*
)
fdt_getprop
(
fdt
,
node
,
"bootargs"
,
&
len
))
{
if
(
auto
value
=
fdt_getprop
(
fdt
,
node
,
"bootargs"
,
&
len
))
{
if
(
char
*
skip
=
strstr
(
value
,
"skip_initramfs"
))
{
if
(
void
*
skip
=
memmem
(
value
,
len
,
"skip_initramfs"
,
14
))
{
fprintf
(
stderr
,
"Patch [skip_initramfs] -> [want_initramfs]
\n
"
);
fprintf
(
stderr
,
"Patch [skip_initramfs] -> [want_initramfs]
\n
"
);
// Don't use strcpy, we do NOT want it null terminated
memcpy
(
skip
,
"want"
,
4
);
memcpy
(
skip
,
"want"
,
4
);
patched
=
true
;
patched
=
true
;
}
}
}
}
break
;
}
}
if
(
int
fstab
=
find_fstab
(
fdt
);
fstab
>=
0
)
{
if
(
int
fstab
=
find_fstab
(
fdt
);
fstab
>=
0
)
{
fdt_for_each_subnode
(
node
,
fdt
,
fstab
)
{
fdt_for_each_subnode
(
node
,
fdt
,
fstab
)
{
...
...
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