mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-6885: Fixing potential path traversal in AndroidProjectCreator
This commit is contained in:
@@ -115,8 +115,7 @@ public class AndroidProjectCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processListing(File outputDirectory, GFileSystem fs, List<GFile> listing,
|
private void processListing(File outputDirectory, GFileSystem fs, List<GFile> listing,
|
||||||
TaskMonitor monitor)
|
TaskMonitor monitor) throws IOException, CancelledException {
|
||||||
throws IOException, CancelledException {
|
|
||||||
for (GFile child : listing) {
|
for (GFile child : listing) {
|
||||||
|
|
||||||
String childName = child.getName();
|
String childName = child.getName();
|
||||||
@@ -131,6 +130,10 @@ public class AndroidProjectCreator {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
File subDir = new File(outputDirectory, childName);
|
File subDir = new File(outputDirectory, childName);
|
||||||
|
if (!FileUtilities.isPathContainedWithin(outputDirectory, subDir)) {
|
||||||
|
Msg.error(this, "Skipping directory with path traversal: " + childName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
FileUtilities.checkedMkdir(subDir);
|
FileUtilities.checkedMkdir(subDir);
|
||||||
processListing(subDir, fs, child.getListing(), monitor);
|
processListing(subDir, fs, child.getListing(), monitor);
|
||||||
continue;
|
continue;
|
||||||
@@ -220,6 +223,9 @@ public class AndroidProjectCreator {
|
|||||||
try (InputStream is = inputFile.getInputStream()) {
|
try (InputStream is = inputFile.getInputStream()) {
|
||||||
FileUtilities.checkedMkdirs(outputDirectory);
|
FileUtilities.checkedMkdirs(outputDirectory);
|
||||||
File destFile = new File(outputDirectory, outputName);
|
File destFile = new File(outputDirectory, outputName);
|
||||||
|
if (!FileUtilities.isPathContainedWithin(outputDirectory, destFile)) {
|
||||||
|
throw new IOException("Path traversal detected in entry name: " + outputName);
|
||||||
|
}
|
||||||
|
|
||||||
monitor.setMessage("Copying [" + inputFile.getName() + "] to Eclipse project...");
|
monitor.setMessage("Copying [" + inputFile.getName() + "] to Eclipse project...");
|
||||||
FileUtilities.copyStreamToFile(is, destFile, false, monitor);
|
FileUtilities.copyStreamToFile(is, destFile, false, monitor);
|
||||||
|
|||||||
Reference in New Issue
Block a user