tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1160349 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/coyote/ajp/ test/org/apache/coyote/ajp/ webapps/docs/
Date Mon, 22 Aug 2011 17:59:28 GMT
Author: markt
Date: Mon Aug 22 17:59:28 2011
New Revision: 1160349

URL: http://svn.apache.org/viewvc?rev=1160349&view=rev
Log:
Ensure AjpMessage header is correct for the direction in which the message is being sent

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java
    tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java
    tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Aug 22 17:59:28 2011
@@ -1 +1 @@
-/tomcat/trunk:1156171,1156276,1156304,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335
+/tomcat/trunk:1156171,1156276,1156304,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1160347

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=1160349&r1=1160348&r2=1160349&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Mon Aug 22 17:59:28
2011
@@ -463,7 +463,7 @@ public class AjpAprProcessor extends Abs
             read(headerLength);
         }
         inputBuffer.get(message.getBuffer(), 0, headerLength);
-        int messageLength = message.processHeader();
+        int messageLength = message.processHeader(true);
         if (messageLength < 0) {
             // Invalid AJP header signature
             // TODO: Throw some exception and close the connection to frontend.

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java?rev=1160349&r1=1160348&r2=1160349&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpMessage.java Mon Aug 22 17:59:28 2011
@@ -348,13 +348,18 @@ public class AjpMessage {
         return buf.length;
     }
     
-    
+    @Deprecated
     public int processHeader() {
+        return processHeader(true);
+    }
+    
+    public int processHeader(boolean toContainer) {
         pos = 0;
         int mark = getInt();
         len = getInt();
         // Verify message signature
-        if ((mark != 0x1234) && (mark != 0x4142)) {
+        if ((toContainer && mark != 0x1234) ||
+                (!toContainer && mark != 0x4142)) {
             log.error(sm.getString("ajpmessage.invalid", "" + mark));
             if (log.isDebugEnabled()) {
                 dump("In: ");

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java?rev=1160349&r1=1160348&r2=1160349&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java Mon Aug 22 17:59:28
2011
@@ -465,7 +465,7 @@ public class AjpNioProcessor extends Abs
             return 0;
         }
         
-        int messageLength = message.processHeader();
+        int messageLength = message.processHeader(true);
         if (messageLength < 0) {
             // Invalid AJP header signature
             throw new IOException(sm.getString("ajpmessage.invalidLength",

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=1160349&r1=1160348&r2=1160349&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Mon Aug 22 17:59:28
2011
@@ -414,7 +414,7 @@ public class AjpProcessor extends Abstra
 
         read(buf, 0, headerLength);
 
-        int messageLength = message.processHeader();
+        int messageLength = message.processHeader(true);
         if (messageLength < 0) {
             // Invalid AJP header signature
             // TODO: Throw some exception and close the connection to frontend.

Modified: tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java?rev=1160349&r1=1160348&r2=1160349&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java Mon Aug 22 17:59:28
2011
@@ -149,7 +149,7 @@ public class SimpleAjpClient {
 
         read(is, buf, 0, headerLength);
 
-        int messageLength = message.processHeader();
+        int messageLength = message.processHeader(false);
         if (messageLength < 0) {
             throw new IOException("Invalid AJP message length");
         } else if (messageLength == 0) {

Modified: tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java?rev=1160349&r1=1160348&r2=1160349&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java Mon Aug
22 17:59:28 2011
@@ -101,7 +101,7 @@ public class TestAbstractAjpProcessor ex
         assertEquals((byte) 'B', message.buf[1]);
         
         // Set the start position and read the length
-        message.processHeader();
+        message.processHeader(false);
         
         // Check the length
         assertTrue(message.len > 0);
@@ -136,7 +136,7 @@ public class TestAbstractAjpProcessor ex
         assertEquals((byte) 'B', message.buf[1]);
         
         // Set the start position and read the length
-        message.processHeader();
+        message.processHeader(false);
         
         // Should be a body chunk message
         assertEquals(0x03, message.readByte());
@@ -153,7 +153,7 @@ public class TestAbstractAjpProcessor ex
         assertEquals((byte) 'A', message.buf[0]);
         assertEquals((byte) 'B', message.buf[1]);
 
-        message.processHeader();
+        message.processHeader(false);
         
         // Should be an end body message
         assertEquals(0x05, message.readByte());

Modified: tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java?rev=1160349&r1=1160348&r2=1160349&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java Mon Aug 22 17:59:28
2011
@@ -67,4 +67,17 @@ public class TesterAjpMessage extends Aj
             return readString(len);
         }
     }
+
+    @Override
+    public void end() {
+        len = pos;
+        int dLen = len - 4;
+
+        buf[0] = (byte) 0x12;
+        buf[1] = (byte) 0x34;
+        buf[2] = (byte) ((dLen>>>8) & 0xFF);
+        buf[3] = (byte) (dLen & 0xFF);
+    }
+
+    
 }

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1160349&r1=1160348&r2=1160349&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Aug 22 17:59:28 2011
@@ -105,6 +105,10 @@
         More changes to align the code between the different HTTP connectors.
         (markt)
       </fix>
+      <fix>
+        Ensure AjpMessage headers are correct for the direction of the message.
+        (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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


Mime
View raw message