File ant-CVE-2020-1945-2.patch of Package ant.23494

From d591851ae3921172bb825b5a5344afa3de0e28ca Mon Sep 17 00:00:00 2001
From: Stefan Bodewig <bodewig@apache.org>
Date: Sun, 3 May 2020 17:24:03 +0200
Subject: [PATCH] make junitlauncher and friends use FileUtils.createTempFile

---
 .../AbstractJUnitResultFormatter.java           |  5 +++--
 .../confined/JUnitLauncherTask.java             | 17 +++++++----------
 2 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
index 833ae0fe6d..dc9847d2a8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
@@ -260,8 +260,9 @@ private void storeToFile(final byte[] data, final int offset, final int length)
         }
 
         private FileOutputStream createFileStore() throws IOException {
-            this.filePath = Files.createTempFile(null, this.tmpFileSuffix);
-            this.filePath.toFile().deleteOnExit();
+            this.filePath = FileUtils.getFileUtils()
+                .createTempFile(null, this.tmpFileSuffix, null, true, true)
+                .toPath();
             return new FileOutputStream(this.filePath.toFile());
         }
 
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
index 3e0e671579..0d16ed082a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
@@ -28,6 +28,7 @@
 import org.apache.tools.ant.types.CommandlineJava;
 import org.apache.tools.ant.types.Environment;
 import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.util.FileUtils;
 
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamWriter;
@@ -224,8 +225,9 @@ private void launchViaReflection(final InVMLaunch launchDefinition) {
     }
 
     private java.nio.file.Path dumpProjectProperties() throws IOException {
-        final java.nio.file.Path propsPath = Files.createTempFile(null, "properties");
-        propsPath.toFile().deleteOnExit();
+        final java.nio.file.Path propsPath = FileUtils.getFileUtils()
+            .createTempFile(null, "properties", null, true, true)
+            .toPath();
         final Hashtable<String, Object> props = this.getProject().getProperties();
         final Properties projProperties = new Properties();
         projProperties.putAll(props);
@@ -364,14 +366,9 @@ private int executeForkedTest(final ForkDefinition forkDefinition, final Command
     }
 
     private java.nio.file.Path newLaunchDefinitionXml() {
-        final java.nio.file.Path xmlFilePath;
-        try {
-            xmlFilePath = Files.createTempFile(null, ".xml");
-        } catch (IOException e) {
-            throw new BuildException("Failed to construct command line for test", e);
-        }
-        xmlFilePath.toFile().deleteOnExit();
-        return xmlFilePath;
+        return FileUtils.getFileUtils()
+            .createTempFile(null, ".xml", null, true, true)
+            .toPath();
     }
 
     private final class InVMLaunch implements LaunchDefinition {
openSUSE Build Service is sponsored by