You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fs...@apache.org on 2020/06/26 14:58:59 UTC

[tomcat] 02/03: Add a iterationCount limited to 20 to prevent StackOverflowError.

This is an automated email from the ASF dual-hosted git repository.

fschumacher pushed a commit to branch pr309-recursion
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 57e83d7c9eaa784d3af54fa57de100c99515f1bc
Author: Jean-Frederic Clere <jf...@gmail.com>
AuthorDate: Fri Jun 26 15:18:30 2020 +0200

    Add a iterationCount limited to 20 to prevent StackOverflowError.
---
 java/org/apache/tomcat/util/IntrospectionUtils.java | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/IntrospectionUtils.java b/java/org/apache/tomcat/util/IntrospectionUtils.java
index 977d33a..17fd47e 100644
--- a/java/org/apache/tomcat/util/IntrospectionUtils.java
+++ b/java/org/apache/tomcat/util/IntrospectionUtils.java
@@ -34,6 +34,7 @@ public final class IntrospectionUtils {
 
     private static final Log log = LogFactory.getLog(IntrospectionUtils.class);
     private static final StringManager sm = StringManager.getManager(IntrospectionUtils.class);
+    private static int iterationCount = 0;
 
     /**
      * Find a method with the right name If found, call the method ( if param is
@@ -340,7 +341,13 @@ public final class IntrospectionUtils {
             return value;
         if (log.isDebugEnabled())
             log.debug("IntrospectionUtils.replaceProperties iter on: " + newval);
-        return replaceProperties(newval, staticProp, dynamicProp, classLoader);
+        iterationCount++;
+        if (iterationCount <20)
+            newval = replaceProperties(newval, staticProp, dynamicProp, classLoader);
+        else
+            log.warn("System property failed to update and remains [" + newval + "]");
+        iterationCount--;
+        return newval;
     }
 
     private static String getProperty(String name, Hashtable<Object, Object> staticProp,


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org