Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SECURITY] Fix Temporary File Information Disclosure Vulnerability #161

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions engine/src/main/java/org/n52/javaps/utils/IOUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static File writeBase64ToFile(InputStream input,

public static File writeStreamToFile(InputStream inputStream,
String extension) throws IOException {
File file = File.createTempFile(FILE + UUID.randomUUID(), "." + extension);
File file = Files.createTempFile(FILE + UUID.randomUUID(), "." + extension).toFile();
return writeStreamToFile(inputStream, extension, file);
}

Expand Down Expand Up @@ -112,7 +112,7 @@ public static File writeStreamToFile(InputStream inputStream,
* if the zipping process fails.
*/
public static File zip(File... files) throws IOException {
File zip = File.createTempFile("zip" + UUID.randomUUID(), ".zip");
File zip = Files.createTempFile("zip" + UUID.randomUUID(), ".zip").toFile();

try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zip))) {
byte[] buffer = new byte[4096];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.ArrayList;

/**
Expand Down Expand Up @@ -127,7 +128,7 @@ private boolean reachedInCoreLimit() throws IOException {
return false;
}

onDiskFile = File.createTempFile("jgit_", ".buffer");
onDiskFile = Files.createTempFile("jgit_", ".buffer").toFile();
diskOut = new FileOutputStream(onDiskFile);

final Block last = blocks.remove(blocks.size() - 1);
Expand Down