You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/12/07 08:59:35 UTC

[tomcat] branch 8.5.x updated: Fix potential infinite loop in SSL tests

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 5d27ddf  Fix potential infinite loop in SSL tests
5d27ddf is described below

commit 5d27ddf24f819f028f82fbaf4e9e27c0ca56623f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Mon Dec 7 08:58:00 2020 +0000

    Fix potential infinite loop in SSL tests
---
 test/org/apache/tomcat/util/net/TestSsl.java | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java
index 6d8bc2b..d489537 100644
--- a/test/org/apache/tomcat/util/net/TestSsl.java
+++ b/test/org/apache/tomcat/util/net/TestSsl.java
@@ -125,7 +125,13 @@ public class TestSsl extends TomcatBaseTest {
                         byte[] endOfHeaders = "\r\n\r\n".getBytes();
                         int found = 0;
                         while (found != endOfHeaders.length) {
-                            if (is.read() == endOfHeaders[found]) {
+                            int c = is.read();
+                            if (c == -1) {
+                                // EOF
+                                System.err.println("Unexpected EOF");
+                                errorCount.incrementAndGet();
+                                break;
+                            } else if (c == endOfHeaders[found]) {
                                 found++;
                             } else {
                                 found = 0;
@@ -252,7 +258,11 @@ public class TestSsl extends TomcatBaseTest {
         char[] endOfHeaders ="\r\n\r\n".toCharArray();
         int found = 0;
         while (found != endOfHeaders.length) {
-            if (r.read() == endOfHeaders[found]) {
+            int c = r.read();
+            if (c == -1) {
+                // EOF
+                Assert.fail("Unexpected EOF");
+            } else if (c == endOfHeaders[found]) {
                 found++;
             } else {
                 found = 0;


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