File ant-CVE-2020-1945-3.patch of Package ant.23494
From 041b058c7bf10a94d56db3ca9dba38cf90ab9943 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig <bodewig@apache.org>
Date: Tue, 5 May 2020 15:01:39 +0200
Subject: [PATCH] make junitlauncher use ant.tmpdir as well
---
manual/Tasks/junitlauncher.html | 4 ++++
.../junitlauncher/AbstractJUnitResultFormatter.java | 10 ++++++----
.../junitlauncher/confined/JUnitLauncherTask.java | 4 ++--
3 files changed, 12 insertions(+), 6 deletions(-)
Index: apache-ant-1.10.7/manual/Tasks/junitlauncher.html
===================================================================
--- apache-ant-1.10.7.orig/manual/Tasks/junitlauncher.html
+++ apache-ant-1.10.7/manual/Tasks/junitlauncher.html
@@ -43,6 +43,10 @@
case is nor does it execute the tests itself.
</p>
<p>
+ This task captures testoutput and configuration data inside of
+ the <a href="../running.html#tmpdir">temporary directory</a>.
+</p>
+<p>
<strong>Note</strong>: This task depends on external libraries not included in the Apache Ant
distribution. See <a href="../install.html#librarydependencies">Library Dependencies</a> for
more information.
Index: apache-ant-1.10.7/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
===================================================================
--- apache-ant-1.10.7.orig/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
+++ apache-ant-1.10.7/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/AbstractJUnitResultFormatter.java
@@ -53,7 +53,7 @@ abstract class AbstractJUnitResultFormat
@Override
public void sysOutAvailable(final byte[] data) {
if (this.sysOutStore == null) {
- this.sysOutStore = new SysOutErrContentStore(true);
+ this.sysOutStore = new SysOutErrContentStore(context, true);
}
try {
this.sysOutStore.store(data);
@@ -65,7 +65,7 @@ abstract class AbstractJUnitResultFormat
@Override
public void sysErrAvailable(final byte[] data) {
if (this.sysErrStore == null) {
- this.sysErrStore = new SysOutErrContentStore(false);
+ this.sysErrStore = new SysOutErrContentStore(context, false);
}
try {
this.sysErrStore.store(data);
@@ -212,13 +212,15 @@ abstract class AbstractJUnitResultFormat
}
};
+ private final TestExecutionContext context;
private final String tmpFileSuffix;
private ByteBuffer inMemoryStore = ByteBuffer.allocate(DEFAULT_CAPACITY_IN_BYTES);
private boolean usingFileStore = false;
private Path filePath;
private FileOutputStream fileOutputStream;
- private SysOutErrContentStore(final boolean isSysOut) {
+ private SysOutErrContentStore(final TestExecutionContext context, final boolean isSysOut) {
+ this.context = context;
this.tmpFileSuffix = isSysOut ? ".sysout" : ".syserr";
}
@@ -261,7 +263,7 @@ abstract class AbstractJUnitResultFormat
private FileOutputStream createFileStore() throws IOException {
this.filePath = FileUtils.getFileUtils()
- .createTempFile(null, this.tmpFileSuffix, null, true, true)
+ .createTempFile(context.getProject().orElse(null), null, this.tmpFileSuffix, null, true, true)
.toPath();
return new FileOutputStream(this.filePath.toFile());
}
Index: apache-ant-1.10.7/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
===================================================================
--- apache-ant-1.10.7.orig/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
+++ apache-ant-1.10.7/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/confined/JUnitLauncherTask.java
@@ -226,7 +226,7 @@ public class JUnitLauncherTask extends T
private java.nio.file.Path dumpProjectProperties() throws IOException {
final java.nio.file.Path propsPath = FileUtils.getFileUtils()
- .createTempFile(null, "properties", null, true, true)
+ .createTempFile(getProject(), null, "properties", null, true, true)
.toPath();
final Hashtable<String, Object> props = this.getProject().getProperties();
final Properties projProperties = new Properties();
@@ -367,7 +367,7 @@ public class JUnitLauncherTask extends T
private java.nio.file.Path newLaunchDefinitionXml() {
return FileUtils.getFileUtils()
- .createTempFile(null, ".xml", null, true, true)
+ .createTempFile(getProject(), null, ".xml", null, true, true)
.toPath();
}