You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rz...@apache.org on 2023/10/11 06:38:06 UTC
[tomee] 02/02: TOMEE-4254 - Backporting changes from https://github.com/apache/tomcat/commit/9375d67106f8df9eb9d7b360b2bef052fe67d3d4 for CVE-2023-42795
This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch tomee-9.x-cve-patches
in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 9cd6858a04a572e26236634fbb1c97a22957dad6
Author: Richard Zowalla <rz...@apache.org>
AuthorDate: Wed Oct 11 08:37:28 2023 +0200
TOMEE-4254 - Backporting changes from https://github.com/apache/tomcat/commit/9375d67106f8df9eb9d7b360b2bef052fe67d3d4 for CVE-2023-42795
---
.../org/apache/catalina/connector/LocalStrings.properties | 1 +
.../patch/java/org/apache/catalina/connector/Request.java | 8 ++++----
.../org/apache/catalina/core/ApplicationHttpRequest.java | 8 +++++++-
.../java/org/apache/catalina/core/LocalStrings.properties | 1 +
.../java/org/apache/tomcat/util/buf/B2CConverter.java | 11 ++++++++++-
.../java/org/apache/tomcat/util/buf/C2BConverter.java | 15 ++++++++++++++-
.../org/apache/tomcat/util/buf/LocalStrings.properties | 3 +++
7 files changed, 40 insertions(+), 7 deletions(-)
diff --git a/tomee/apache-tomee/src/patch/java/org/apache/catalina/connector/LocalStrings.properties b/tomee/apache-tomee/src/patch/java/org/apache/catalina/connector/LocalStrings.properties
index 5cfd969f13..b0b9bba438 100644
--- a/tomee/apache-tomee/src/patch/java/org/apache/catalina/connector/LocalStrings.properties
+++ b/tomee/apache-tomee/src/patch/java/org/apache/catalina/connector/LocalStrings.properties
@@ -47,6 +47,7 @@ coyoteRequest.attributeEvent=Exception thrown by attributes event listener
coyoteRequest.authenticate.ise=Cannot call authenticate() after the response has been committed
coyoteRequest.changeSessionId=Cannot change session ID. There is no session associated with this request.
coyoteRequest.chunkedPostTooLarge=Parameters were not parsed because the size of the posted data was too big. Because this request was a chunked request, it could not be processed further. Use the maxPostSize attribute of the connector to resolve this if the application should accept large POSTs.
+coyoteRequest.deletePartFailed=Failed to deleted temporary file used for part [{0}]
coyoteRequest.filterAsyncSupportUnknown=Unable to determine if any filters do not support async processing
coyoteRequest.getContextPath.ise=Unable to find match between the canonical context path [{0}] and the URI presented by the user agent [{1}]
coyoteRequest.getInputStream.ise=getReader() has already been called for this request
diff --git a/tomee/apache-tomee/src/patch/java/org/apache/catalina/connector/Request.java b/tomee/apache-tomee/src/patch/java/org/apache/catalina/connector/Request.java
index 5f0b56e826..a617111c58 100644
--- a/tomee/apache-tomee/src/patch/java/org/apache/catalina/connector/Request.java
+++ b/tomee/apache-tomee/src/patch/java/org/apache/catalina/connector/Request.java
@@ -449,8 +449,9 @@ public class Request implements HttpServletRequest {
for (Part part: parts) {
try {
part.delete();
- } catch (IOException ignored) {
- // ApplicationPart.delete() never throws an IOEx
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ log.warn(sm.getString("coyoteRequest.deletePartFailed", part.getName()), t);
}
}
parts = null;
@@ -502,9 +503,8 @@ public class Request implements HttpServletRequest {
asyncSupported = null;
if (asyncContext!=null) {
- asyncContext.recycle();
+ asyncContext = null;
}
- asyncContext = null;
}
diff --git a/tomee/apache-tomee/src/patch/java/org/apache/catalina/core/ApplicationHttpRequest.java b/tomee/apache-tomee/src/patch/java/org/apache/catalina/core/ApplicationHttpRequest.java
index 6d6dd6fe38..0c36f12a0b 100644
--- a/tomee/apache-tomee/src/patch/java/org/apache/catalina/core/ApplicationHttpRequest.java
+++ b/tomee/apache-tomee/src/patch/java/org/apache/catalina/core/ApplicationHttpRequest.java
@@ -48,6 +48,7 @@ import org.apache.catalina.connector.RequestFacade;
import org.apache.catalina.util.ParameterMap;
import org.apache.catalina.util.RequestUtil;
import org.apache.catalina.util.URLEncoder;
+import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.buf.B2CConverter;
import org.apache.tomcat.util.buf.MessageBytes;
import org.apache.tomcat.util.http.Parameters;
@@ -650,7 +651,12 @@ class ApplicationHttpRequest extends HttpServletRequestWrapper {
*/
public void recycle() {
if (session != null) {
- session.endAccess();
+ try {
+ session.endAccess();
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ context.getLogger().warn(sm.getString("applicationHttpRequest.sessionEndAccessFail"), t);
+ }
}
}
diff --git a/tomee/apache-tomee/src/patch/java/org/apache/catalina/core/LocalStrings.properties b/tomee/apache-tomee/src/patch/java/org/apache/catalina/core/LocalStrings.properties
index bc9778aa87..07b47be594 100644
--- a/tomee/apache-tomee/src/patch/java/org/apache/catalina/core/LocalStrings.properties
+++ b/tomee/apache-tomee/src/patch/java/org/apache/catalina/core/LocalStrings.properties
@@ -59,6 +59,7 @@ applicationFilterRegistration.nullInitParam=Unable to set initialisation paramet
applicationFilterRegistration.nullInitParams=Unable to set initialisation parameters for filter due to null name and/or value. Name [{0}], Value [{1}]
applicationHttpRequest.fragmentInDispatchPath=The fragment in dispatch path [{0}] has been removed
+applicationHttpRequest.sessionEndAccessFail=Exception triggered ending access to session while recycling request
applicationPushBuilder.methodInvalid=The HTTP method for a push request must be both cacheable and safe but [{0}] is not
applicationPushBuilder.methodNotToken=HTTP methods must be tokens but [{0}] contains a non-token character
diff --git a/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/B2CConverter.java b/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/B2CConverter.java
index 532c209ec9..98f989b0f7 100644
--- a/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/B2CConverter.java
+++ b/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/B2CConverter.java
@@ -27,6 +27,9 @@ import java.nio.charset.CodingErrorAction;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.res.StringManager;
/**
@@ -34,6 +37,7 @@ import org.apache.tomcat.util.res.StringManager;
*/
public class B2CConverter {
+ private static final Log log = LogFactory.getLog(B2CConverter.class);
private static final StringManager sm = StringManager.getManager(B2CConverter.class);
private static final CharsetCache charsetCache = new CharsetCache();
@@ -106,7 +110,12 @@ public class B2CConverter {
* Reset the decoder state.
*/
public void recycle() {
- decoder.reset();
+ try {
+ decoder.reset();
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ log.warn(sm.getString("b2cConverter.decoderResetFail", decoder.charset()), t);
+ }
leftovers.position(0);
}
diff --git a/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/C2BConverter.java b/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/C2BConverter.java
index 4b27f6c980..df23d5bb17 100644
--- a/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/C2BConverter.java
+++ b/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/C2BConverter.java
@@ -24,11 +24,19 @@ import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
+import org.apache.juli.logging.Log;
+import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.ExceptionUtils;
+import org.apache.tomcat.util.res.StringManager;
+
/**
* NIO based character encoder.
*/
public final class C2BConverter {
+ private static final Log log = LogFactory.getLog(C2BConverter.class);
+ private static final StringManager sm = StringManager.getManager(C2BConverter.class);
+
private final CharsetEncoder encoder;
private ByteBuffer bb = null;
private CharBuffer cb = null;
@@ -50,7 +58,12 @@ public final class C2BConverter {
* Reset the encoder state.
*/
public void recycle() {
- encoder.reset();
+ try {
+ encoder.reset();
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
+ log.warn(sm.getString("c2bConverter.decoderResetFail", encoder.charset()), t);
+ }
leftovers.position(0);
}
diff --git a/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/LocalStrings.properties b/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/LocalStrings.properties
index cd883e6f57..25cdd8d4f9 100644
--- a/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/LocalStrings.properties
+++ b/tomee/apache-tomee/src/patch/java/org/apache/tomcat/util/buf/LocalStrings.properties
@@ -16,10 +16,13 @@
asn1Parser.lengthInvalid=Invalid length [{0}] bytes reported when the input data length is [{1}] bytes
asn1Parser.tagMismatch=Expected to find value [{0}] but found value [{1}]
+b2cConverter.decoderResetFail=Failed to reset instance of decoder for character set [{0}]
b2cConverter.unknownEncoding=The character encoding [{0}] is not supported
byteBufferUtils.cleaner=Cannot use direct ByteBuffer cleaner, memory leaking may occur
+c2bConverter.encoderResetFail=Failed to reset instance of encoder for character set [{0}]
+
chunk.overflow=Buffer overflow and no sink is set, limit [{0}] and buffer length [{1}]
encodedSolidusHandling.invalid=The value [{0}] is not recognised