Skip to content

Commit

Permalink
Merge pull request #177 from BulkSecurityGeneratorProjectV2/fix/JLL/t…
Browse files Browse the repository at this point in the history
…emporary_directory_hijacking_or_temporary_directory_information_disclosure

[SECURITY] Fix Temporary Directory Hijacking or Information Disclosure Vulnerability
  • Loading branch information
headius authored Oct 17, 2022
2 parents a2100e3 + f1de408 commit f67be1c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/test/java/jnr/posix/windows/WindowsFileTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.RandomAccessFile;
import java.nio.file.Files;
import java.text.NumberFormat;
import jnr.posix.DummyPOSIXHandler;
import jnr.posix.FileStat;
Expand All @@ -15,8 +16,8 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import static org.junit.Assert.assertTrue;

public class WindowsFileTest {
private static POSIX posix;

Expand Down Expand Up @@ -52,9 +53,7 @@ public void cleanup(File node) {
// FIXME: This is a broken method since it does not delete any of the generated dirs.
private static final String DIR_NAME = "0123456789";
private Pair makeLongPath() throws IOException {
File tmp = File.createTempFile("temp", Long.toHexString(System.nanoTime()));

if (!(tmp.delete() && tmp.mkdir())) throw new IOException("Could not make a long path");
File tmp = Files.createTempDirectory("temp" + Long.toHexString(System.nanoTime())).toFile();

StringBuilder buf = new StringBuilder(DIR_NAME);
for (int i = 0; i < 30; i++) {
Expand Down

0 comments on commit f67be1c

Please sign in to comment.