mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-02 07:48:16 +08:00
GP-6455: Check to make sure we aren't unzipping theme zip files to
outside the user settings directory
This commit is contained in:
@@ -24,6 +24,7 @@ import org.apache.commons.io.FileUtils;
|
||||
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.util.Msg;
|
||||
import utilities.util.FileUtilities;
|
||||
|
||||
/**
|
||||
* Reads Themes from a file or {@link Reader}
|
||||
@@ -138,6 +139,9 @@ class ThemeReader extends AbstractThemeReader {
|
||||
String relativePath = path.substring(indexOf, path.length());
|
||||
File dir = Application.getUserSettingsDirectory();
|
||||
File iconFile = new File(dir, relativePath);
|
||||
if (!FileUtilities.isPathContainedWithin(dir, iconFile)) {
|
||||
throw new IOException("Zip entry escapes target directory: " + relativePath);
|
||||
}
|
||||
FileUtils.copyInputStreamToFile(is, iconFile);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user