mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-06-24 06:44:19 -04:00
Merge 05c88a17e9
into 32148e7440
This commit is contained in:
commit
3b5ebff1ed
2 changed files with 5 additions and 1 deletions
|
@ -502,7 +502,7 @@ public class PersistenceManager<T extends PersistableEnvelope> {
|
||||||
|
|
||||||
tempFile = usedTempFilePath != null
|
tempFile = usedTempFilePath != null
|
||||||
? FileUtil.createNewFile(usedTempFilePath)
|
? FileUtil.createNewFile(usedTempFilePath)
|
||||||
: File.createTempFile("temp_" + fileName, null, dir);
|
: Files.createTempFile(dir.toPath(), "temp_" + fileName, null).toFile();
|
||||||
// Don't use a new temp file path each time, as that causes the delete-on-exit hook to leak memory:
|
// Don't use a new temp file path each time, as that causes the delete-on-exit hook to leak memory:
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,10 @@ public class ZipUtils {
|
||||||
int count;
|
int count;
|
||||||
while ((entry = zipStream.getNextEntry()) != null) {
|
while ((entry = zipStream.getNextEntry()) != null) {
|
||||||
File file = new File(dir, entry.getName());
|
File file = new File(dir, entry.getName());
|
||||||
|
if (!file.toPath().normalize().startsWith(dir.toPath())) {
|
||||||
|
throw new SecurityException("ZIP entry contains path traversal attempt: " + entry.getName());
|
||||||
|
}
|
||||||
|
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) {
|
||||||
file.mkdirs();
|
file.mkdirs();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue