tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1160347 - in /tomcat/trunk: java/org/apache/coyote/ajp/ test/org/apache/coyote/ajp/
Date Mon, 22 Aug 2011 17:55:14 GMT
Author: markt
Date: Mon Aug 22 17:55:14 2011
New Revision: 1160347

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

Modified:
    tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpMessage.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
    tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
    tomcat/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java
    tomcat/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java
    tomcat/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java

Modified: tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=1160347&r1=1160346&r2=1160347&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Mon Aug 22 17:55:14 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/trunk/java/org/apache/coyote/ajp/AjpMessage.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpMessage.java?rev=1160347&r1=1160346&r2=1160347&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpMessage.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpMessage.java Mon Aug 22 17:55:14 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/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java?rev=1160347&r1=1160346&r2=1160347&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java Mon Aug 22 17:55:14 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/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=1160347&r1=1160346&r2=1160347&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Mon Aug 22 17:55:14 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/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java?rev=1160347&r1=1160346&r2=1160347&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java (original)
+++ tomcat/trunk/test/org/apache/coyote/ajp/SimpleAjpClient.java Mon Aug 22 17:55:14 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/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java?rev=1160347&r1=1160346&r2=1160347&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java (original)
+++ tomcat/trunk/test/org/apache/coyote/ajp/TestAbstractAjpProcessor.java Mon Aug 22 17:55:14
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/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java?rev=1160347&r1=1160346&r2=1160347&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java (original)
+++ tomcat/trunk/test/org/apache/coyote/ajp/TesterAjpMessage.java Mon Aug 22 17:55:14 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);
+    }
+
+    
 }



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


Mime
View raw message