Skip to content

Commit

Permalink
Fix for error CWE-377
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Sep 10, 2024
1 parent 2008243 commit a1279d1
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.concurrent.atomic.AtomicBoolean;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -53,7 +54,10 @@
*/
public class AS4ResourceHelper implements Closeable
{
private static final String TEMP_FILE_PREFIX = "phase4-res-";
private static final String TEMP_FILE_SUFFIX = ".tmp";
private static final Logger LOGGER = LoggerFactory.getLogger (AS4ResourceHelper.class);

private static File s_aTempDir;

/**
Expand Down Expand Up @@ -110,7 +114,12 @@ public File createTempFile () throws IOException
throw new IllegalStateException ("ResourceManager is already closing/closed!");

// Create
final File ret = File.createTempFile ("phase4-res-", ".tmp", s_aTempDir);
final File ret = s_aTempDir != null ? Files.createTempFile (s_aTempDir.toPath (),
TEMP_FILE_PREFIX,
TEMP_FILE_SUFFIX).toFile () : Files.createTempFile (
TEMP_FILE_PREFIX,
TEMP_FILE_SUFFIX)
.toFile ();
// And remember
m_aRWLock.writeLocked ( () -> m_aTempFiles.add (ret));

Expand Down

0 comments on commit a1279d1

Please sign in to comment.