On 30.08.2012 23:57, ma...@apache.org wrote:
Author: markt
Date: Thu Aug 30 21:57:15 2012
New Revision: 1379178

URL: http://svn.apache.org/viewvc?rev=1379178&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53677
Ensure a 500 response of the HTTP headers exceed the size limit

Added:
     tomcat/trunk/java/org/apache/coyote/http11/HeadersTooLargeException.java   
(with props)
Modified:
     tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
     tomcat/trunk/java/org/apache/coyote/http11/AbstractOutputBuffer.java
     tomcat/trunk/test/org/apache/coyote/http11/TestAbstractHttp11Processor.java

Modified: 
tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1379178&r1=1379177&r2=1379178&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java 
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Thu 
Aug 30 21:57:15 2012
@@ -761,12 +761,21 @@ public abstract class AbstractHttp11Proc

              // Validate and write response headers
              try {
-                prepareResponse();
+//                try {
+                    prepareResponse();
+//                } catch (IllegalStateException e) {
+                    // Headers too big. Likely too late to do anything about it
+//                    response.reset();
+//                    response.setStatus(500);
+//                    response.setHeader("Connection", "close");
+//                    response.sendHeaders();
+//                }

Not sure but the above commented out code looks like a leftover from an earlier attempt, before the code was latter moved further down. If I'm right you might want to remove the above change. At least it would fit to your prefered slogan "Remove unused code" :)

Same for TC 7.

                  getOutputBuffer().commit();
              } catch (IOException e) {
                  // Set error flag
                  error = true;
              }
+
          } else if (actionCode == ActionCode.ACK) {
              // Acknowledge request
              // Send a 100 status back if it makes sense (response not 
committed
@@ -1009,6 +1018,15 @@ public abstract class AbstractHttp11Proc
                      setCometTimeouts(socketWrapper);
                  } catch (InterruptedIOException e) {
                      error = true;
+                } catch (HeadersTooLargeException e) {
+                    error = true;
+                    // The response should not have been committed but check it
+                    // anyway to be safe
+                    if (!response.isCommitted()) {
+                        response.reset();
+                        response.setStatus(500);
+                        response.setHeader("Connection", "close");
+                    }
                  } catch (Throwable t) {
                      ExceptionUtils.handleThrowable(t);
                      getLog().error(sm.getString(

Regards,

Rainer

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

Reply via email to