This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push: new 4d207d165e Improve handling of stack overflow errors when parsing SSI expressions. 4d207d165e is described below commit 4d207d165e824f04209eef1de30a3fa46cbeec59 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 | 15 +++++++++++++-- .../apache/catalina/ssi/SSIStopProcessingException.java | 8 ++++++++ webapps/docs/changelog.xml | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/ssi/ExpressionParseTree.java b/java/org/apache/catalina/ssi/ExpressionParseTree.java index 1d58f70530..514d13df95 100644 --- a/java/org/apache/catalina/ssi/ExpressionParseTree.java +++ b/java/org/apache/catalina/ssi/ExpressionParseTree.java @@ -22,6 +22,9 @@ import java.util.LinkedList; import java.util.List; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; + +import org.apache.tomcat.util.ExceptionUtils; + /** * Represents a parsed expression. * @@ -64,10 +67,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 6b624b08c3..4cdaf869cc 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -112,6 +112,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="Jasper"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org