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
1c06b04c
Commit
1c06b04c
authored
Sep 06, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use GNU tar format
parent
2ee22fd3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
8 deletions
+43
-8
TarEntry.java
app/src/main/java/com/topjohnwu/magisk/utils/TarEntry.java
+42
-5
ZipUtils.java
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
+1
-3
No files found.
app/src/main/java/com/topjohnwu/magisk/utils/TarEntry.java
View file @
1c06b04c
...
...
@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.utils;
import
org.kamranzafar.jtar.TarHeader
;
import
java.io.File
;
import
java.util.Arrays
;
public
class
TarEntry
extends
org
.
kamranzafar
.
jtar
.
TarEntry
{
...
...
@@ -10,10 +11,6 @@ public class TarEntry extends org.kamranzafar.jtar.TarEntry {
super
(
file
,
entryName
);
}
public
TarEntry
(
byte
[]
headerBuf
)
{
super
(
headerBuf
);
}
/*
* Workaround missing java.nio.file.attribute.PosixFilePermission
* Simply just assign a default permission to the file
...
...
@@ -21,7 +18,47 @@ public class TarEntry extends org.kamranzafar.jtar.TarEntry {
@Override
public
void
extractTarHeader
(
String
entryName
)
{
int
permissions
=
file
.
isDirectory
()
?
0
40755
:
01
00644
;
int
permissions
=
file
.
isDirectory
()
?
0
00755
:
0
00644
;
header
=
TarHeader
.
createHeader
(
entryName
,
file
.
length
(),
file
.
lastModified
()
/
1000
,
file
.
isDirectory
(),
permissions
);
header
.
userName
=
new
StringBuffer
(
""
);
header
.
groupName
=
header
.
userName
;
}
/*
* Rewrite the header to GNU format
* */
@Override
public
void
writeEntryHeader
(
byte
[]
outbuf
)
{
super
.
writeEntryHeader
(
outbuf
);
System
.
arraycopy
(
"ustar \0"
.
getBytes
(),
0
,
outbuf
,
257
,
TarHeader
.
USTAR_MAGICLEN
);
getOctalBytes
(
header
.
mode
,
outbuf
,
100
,
TarHeader
.
MODELEN
);
getOctalBytes
(
header
.
userId
,
outbuf
,
108
,
TarHeader
.
UIDLEN
);
getOctalBytes
(
header
.
groupId
,
outbuf
,
116
,
TarHeader
.
GIDLEN
);
getOctalBytes
(
header
.
size
,
outbuf
,
124
,
TarHeader
.
SIZELEN
);
getOctalBytes
(
header
.
modTime
,
outbuf
,
136
,
TarHeader
.
MODTIMELEN
);
Arrays
.
fill
(
outbuf
,
148
,
148
+
TarHeader
.
CHKSUMLEN
,
(
byte
)
' '
);
Arrays
.
fill
(
outbuf
,
329
,
329
+
TarHeader
.
USTAR_DEVLEN
,
(
byte
)
'\0'
);
Arrays
.
fill
(
outbuf
,
337
,
337
+
TarHeader
.
USTAR_DEVLEN
,
(
byte
)
'\0'
);
// Recalculate checksum
getOctalBytes
(
computeCheckSum
(
outbuf
),
outbuf
,
148
,
TarHeader
.
CHKSUMLEN
);
}
/*
* Proper octal to ASCII conversion
* */
private
void
getOctalBytes
(
long
value
,
byte
[]
buf
,
int
offset
,
int
length
)
{
int
idx
=
length
-
1
;
buf
[
offset
+
idx
]
=
0
;
--
idx
;
for
(
long
val
=
value
;
idx
>=
0
;
--
idx
)
{
buf
[
offset
+
idx
]
=
(
byte
)
((
byte
)
'0'
+
(
byte
)
(
val
&
7
));
val
=
val
>>
3
;
}
}
}
app/src/main/java/com/topjohnwu/magisk/utils/ZipUtils.java
View file @
1c06b04c
...
...
@@ -127,9 +127,7 @@ public class ZipUtils {
// Patch binary XML with new package name
pkg
=
Utils
.
genPackageName
(
"com."
,
UNHIDE_PKG_NAME
.
length
-
1
);
for
(
int
i
=
0
;
i
<
pkg
.
length
();
++
i
)
{
xml
[
offset
+
i
]
=
(
byte
)
pkg
.
charAt
(
i
);
}
System
.
arraycopy
(
pkg
.
getBytes
(),
0
,
xml
,
offset
,
pkg
.
length
());
dest
.
write
(
xml
);
}
else
{
while
((
size
=
source
.
read
(
buffer
))
!=
-
1
)
{
...
...
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