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 Directory Hijacking or Information Disclosure Vulnerability #13

Open
wants to merge 1 commit into
base: master
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;

import java.util.Set;
/**
*
* @author [email protected]
Expand Down Expand Up @@ -56,13 +57,7 @@ static String getJavaPackage(File sourceFile, File classPathRoot) {
}

static File createTempDirectory() throws IOException {
final File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
if(!(temp.delete())) {
throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
}
if(!(temp.mkdir())) {
throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());
}
final File temp = Files.createTempDirectory("temp" + Long.toString(System.nanoTime())).toFile();
return temp;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLClassLoader;
import java.nio.file.Files;

import ma.glasnost.orika.impl.generator.EclipseJdtCompiler;
import ma.glasnost.orika.test.MavenProjectUtil;
Expand All @@ -40,16 +41,7 @@ public class MultiLayeredClassloaderTestCase {
* @throws IOException
*/
public static File createTempDirectory() throws IOException {
final File temp = File.createTempFile("temp",
Long.toString(System.nanoTime()));
if (!(temp.delete())) {
throw new IOException("Could not delete temp file: "
+ temp.getAbsolutePath());
}
if (!(temp.mkdir())) {
throw new IOException("Could not create temp directory: "
+ temp.getAbsolutePath());
}
final File temp = Files.createTempDirectory("temp" + Long.toString(System.nanoTime())).toFile();
return temp;
}

Expand Down