Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jadx
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
open-source
jadx
Commits
cab3f5da
Commit
cab3f5da
authored
Apr 25, 2019
by
Ahmed Ashour
Committed by
skylot
Apr 25, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: always use FileUtils.createTempFile (PR #634)
parent
77cee15d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
26 deletions
+13
-26
ClsSet.java
jadx-core/src/main/java/jadx/core/clsp/ClsSet.java
+1
-3
FileUtils.java
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
+4
-15
InputFile.java
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
+7
-7
JadxArgsValidatorOutDirsTest.java
.../src/test/java/jadx/api/JadxArgsValidatorOutDirsTest.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/core/clsp/ClsSet.java
View file @
cab3f5da
...
...
@@ -168,7 +168,7 @@ public class ClsSet {
save
(
outputStream
);
}
}
else
if
(
outputName
.
endsWith
(
".jar"
))
{
Path
temp
=
File
s
.
createTempFile
(
"jadx"
,
".zip"
);
Path
temp
=
File
Utils
.
createTempFile
(
".zip"
);
Files
.
copy
(
path
,
temp
,
StandardCopyOption
.
REPLACE_EXISTING
);
try
(
ZipOutputStream
out
=
new
ZipOutputStream
(
Files
.
newOutputStream
(
path
));
...
...
@@ -185,8 +185,6 @@ public class ClsSet {
entry
=
in
.
getNextEntry
();
}
}
Files
.
delete
(
temp
);
}
else
{
throw
new
JadxRuntimeException
(
"Unknown file format: "
+
outputName
);
}
...
...
jadx-core/src/main/java/jadx/core/utils/files/FileUtils.java
View file @
cab3f5da
...
...
@@ -65,24 +65,13 @@ public class FileUtils {
}
}
public
static
File
createTempFile
(
String
suffix
)
{
File
temp
;
public
static
Path
createTempFile
(
String
suffix
)
{
try
{
temp
=
File
.
createTempFile
(
"jadx-tmp-"
,
System
.
nanoTime
()
+
'-'
+
suffix
);
temp
.
deleteOnExit
();
}
catch
(
IOException
e
)
{
throw
new
JadxRuntimeException
(
"Failed to create temp file with suffix: "
+
suffix
);
}
return
temp
;
}
public
static
File
createTempDir
(
String
suffix
)
{
try
{
Path
path
=
Files
.
createTempDirectory
(
"jadx-tmp-"
+
System
.
nanoTime
()
+
'-'
+
suffix
);
Path
path
=
Files
.
createTempFile
(
"jadx-tmp-"
,
suffix
);
path
.
toFile
().
deleteOnExit
();
return
path
.
toFile
()
;
return
path
;
}
catch
(
IOException
e
)
{
throw
new
JadxRuntimeException
(
"Failed to create temp
directory
with suffix: "
+
suffix
);
throw
new
JadxRuntimeException
(
"Failed to create temp
file
with suffix: "
+
suffix
);
}
}
...
...
jadx-core/src/main/java/jadx/core/utils/files/InputFile.java
View file @
cab3f5da
...
...
@@ -4,9 +4,9 @@ import static jadx.core.utils.files.FileUtils.isApkFile;
import
static
jadx
.
core
.
utils
.
files
.
FileUtils
.
isZipDexFile
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.StandardCopyOption
;
...
...
@@ -58,7 +58,7 @@ public class InputFile {
return
;
}
if
(
fileName
.
endsWith
(
".smali"
))
{
Path
output
=
File
s
.
createTempFile
(
"jadx"
,
".dex"
);
Path
output
=
File
Utils
.
createTempFile
(
".dex"
);
SmaliOptions
options
=
new
SmaliOptions
();
options
.
outputDexFile
=
output
.
toAbsolutePath
().
toString
();
Smali
.
assemble
(
options
,
file
.
getAbsolutePath
());
...
...
@@ -134,7 +134,7 @@ public class InputFile {
case
".jar"
:
index
++;
Path
jarFile
=
File
s
.
createTempFile
(
entryName
,
".jar"
);
Path
jarFile
=
File
Utils
.
createTempFile
(
entryName
);
Files
.
copy
(
inputStream
,
jarFile
,
StandardCopyOption
.
REPLACE_EXISTING
);
for
(
Dex
dex
:
loadFromJar
(
jarFile
))
{
addDexFile
(
entryName
,
dex
);
...
...
@@ -145,11 +145,11 @@ public class InputFile {
throw
new
JadxRuntimeException
(
"Unexpected extension in zip: "
+
ext
);
}
}
else
if
(
entryName
.
equals
(
"instant-run.zip"
)
&&
ext
.
equals
(
".dex"
))
{
File
jarFile
=
FileUtils
.
createTempFile
(
"instant-run.zip"
);
try
(
FileOutputStream
fos
=
new
File
OutputStream
(
jarFile
))
{
Path
jarFile
=
FileUtils
.
createTempFile
(
"instant-run.zip"
);
try
(
OutputStream
fos
=
Files
.
new
OutputStream
(
jarFile
))
{
IOUtils
.
copy
(
inputStream
,
fos
);
}
InputFile
tempFile
=
new
InputFile
(
jarFile
);
InputFile
tempFile
=
new
InputFile
(
jarFile
.
toFile
()
);
tempFile
.
loadFromZip
(
ext
);
List
<
DexFile
>
dexFiles
=
tempFile
.
getDexFiles
();
if
(!
dexFiles
.
isEmpty
())
{
...
...
@@ -196,7 +196,7 @@ public class InputFile {
}
private
static
List
<
Dex
>
loadFromClassFile
(
File
file
)
throws
IOException
,
DecodeException
{
Path
outFile
=
File
s
.
createTempFile
(
"cls"
,
".jar"
);
Path
outFile
=
File
Utils
.
createTempFile
(
".jar"
);
try
(
JarOutputStream
jo
=
new
JarOutputStream
(
Files
.
newOutputStream
(
outFile
)))
{
String
clsName
=
AsmUtils
.
getNameFromClassFile
(
file
);
if
(
clsName
==
null
||
!
ZipSecurity
.
isValidZipEntryName
(
clsName
))
{
...
...
jadx-core/src/test/java/jadx/api/JadxArgsValidatorOutDirsTest.java
View file @
cab3f5da
...
...
@@ -66,7 +66,7 @@ public class JadxArgsValidatorOutDirsTest {
private
JadxArgs
makeArgs
()
{
JadxArgs
args
=
new
JadxArgs
();
args
.
getInputFiles
().
add
(
FileUtils
.
createTempFile
(
"some.apk"
));
args
.
getInputFiles
().
add
(
FileUtils
.
createTempFile
(
"some.apk"
)
.
toFile
()
);
return
args
;
}
}
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