This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 43dc48bde7 Improve handling of stack overflow errors when parsing SSI expressions. 43dc48bde7 is described below commit 43dc48bde7fa08e3dbc3d70dad615da48ad6f12f Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Aug 18 19:20:07 2022 +0100 Improve handling of stack overflow errors when parsing SSI expressions. --- java/org/apache/catalina/ssi/ExpressionParseTree.java | 13 +++++++++++-- .../org/apache/catalina/ssi/SSIStopProcessingException.java | 8 ++++++++ webapps/docs/changelog.xml | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/ssi/ExpressionParseTree.java b/java/org/apache/catalina/ssi/ExpressionParseTree.java index 0052d27c87..a6b7afc9e7 100644 --- a/java/org/apache/catalina/ssi/ExpressionParseTree.java +++ b/java/org/apache/catalina/ssi/ExpressionParseTree.java @@ -24,6 +24,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; +import org.apache.tomcat.util.ExceptionUtils; import org.apache.tomcat.util.res.StringManager; /** * Represents a parsed expression. @@ -68,10 +69,18 @@ public class ExpressionParseTree { /** * Evaluates the tree and returns true or false. The specified SSIMediator * is used to resolve variable references. + * * @return the evaluation result + * + * @throws SSIStopProcessingException If an error occurs evaluating the tree */ - public boolean evaluateTree() { - return root.evaluate(); + public boolean evaluateTree() throws SSIStopProcessingException { + try { + return root.evaluate(); + } catch (Throwable t) { + ExceptionUtils.handleThrowable(t); + throw new SSIStopProcessingException(t); + } } diff --git a/java/org/apache/catalina/ssi/SSIStopProcessingException.java b/java/org/apache/catalina/ssi/SSIStopProcessingException.java index e967785e8a..c31bd7baf7 100644 --- a/java/org/apache/catalina/ssi/SSIStopProcessingException.java +++ b/java/org/apache/catalina/ssi/SSIStopProcessingException.java @@ -27,6 +27,14 @@ package org.apache.catalina.ssi; */ public class SSIStopProcessingException extends Exception { + public SSIStopProcessingException() { + super(); + } + + public SSIStopProcessingException(Throwable cause) { + super(cause); + } + private static final long serialVersionUID = 1L; // No specific functionality for this class } \ No newline at end of file diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 747fd2971f..b19c23fd7c 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -133,6 +133,10 @@ <code>INFO</code>. Pull request <pr>533</pr> provided by Piotr P. Karwasz. (markt) </fix> + <fix> + Improve handling of stack overflow errors when parsing SSI expressions. + (markt) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org