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

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new e8bcbf1  Ignore exception getting content length
e8bcbf1 is described below

commit e8bcbf1a017e598498343ebd05f77f07934910bb
Author: remm <r...@apache.org>
AuthorDate: Fri Jun 5 14:21:39 2020 +0200

    Ignore exception getting content length
    
    If the value is invalid, there will be another attempt to convert the
    number with no really easy way out. Ignore the exception which already
    happened in prepareRequest.
---
 java/org/apache/coyote/http11/Http11Processor.java | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 897c2d9..00469e1 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -528,8 +528,16 @@ public class Http11Processor extends AbstractProcessor {
 
 
     private void checkMaxSwallowSize() {
-        if (request.getContentLengthLong() > 0 &&
-                (request.getContentLengthLong() - request.getBytesRead() > 
protocol.getMaxSwallowSize())) {
+        // Parse content-length header
+        long contentLength = -1;
+        try {
+            contentLength = request.getContentLengthLong();
+        } catch (Exception e) {
+            // Ignore, an error here is already processed in prepareRequest
+            // but is done again since the content length is still -1
+        }
+        if (contentLength > 0 &&
+                (contentLength - request.getBytesRead() > 
protocol.getMaxSwallowSize())) {
             // There is more data to swallow than Tomcat will accept so the
             // connection is going to be closed. Disable keep-alive which will
             // trigger adding the "Connection: close" header if not already


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

Reply via email to