Tweak the message validation.
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 25 Aug 2011 14:45:13 +0000 (14:45 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 25 Aug 2011 14:45:13 +0000 (14:45 +0000)
Body messages don't have terminators

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1161584 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AjpAprProcessor.java
java/org/apache/coyote/ajp/AjpMessage.java
java/org/apache/coyote/ajp/AjpNioProcessor.java
java/org/apache/coyote/ajp/AjpProcessor.java

index 6ccbeab..078f2b6 100644 (file)
@@ -372,7 +372,7 @@ public class AjpAprProcessor extends AbstractAjpProcessor<Long> {
             return false;
         }
 
-        bodyMessage.getBytes(bodyBytes);
+        bodyMessage.getBodyBytes(bodyBytes);
         empty = false;
         return true;
     }
index 5bfd1a1..8986955 100644 (file)
@@ -312,16 +312,30 @@ public class AjpMessage {
 
     
     public void getBytes(MessageBytes mb) {
+        doGetBytes(mb, true);
+    }
+    
+    public void getBodyBytes(MessageBytes mb) {
+        doGetBytes(mb, false);
+    }
+    
+    private void doGetBytes(MessageBytes mb, boolean terminated) {
         int length = getInt();
         if ((length == 0xFFFF) || (length == -1)) {
             mb.recycle();
             return;
         }
-        validatePos(pos + length + 1);
+        if (terminated) {
+            validatePos(pos + length + 1);
+        } else {
+            validatePos(pos + length);
+        }
         mb.setBytes(buf, pos, length);
         mb.getCharChunk().recycle(); // not valid anymore
         pos += length;
-        pos++; // Skip the terminating \0
+        if (terminated) {
+            pos++; // Skip the terminating \0
+        }
     }
     
     
index f6500a1..f1669dd 100644 (file)
@@ -378,7 +378,7 @@ public class AjpNioProcessor extends AbstractAjpProcessor<NioChannel> {
             return false;
         }
 
-        bodyMessage.getBytes(bodyBytes);
+        bodyMessage.getBodyBytes(bodyBytes);
         empty = false;
         return true;
     }
index 543f89f..376327c 100644 (file)
@@ -335,7 +335,7 @@ public class AjpProcessor extends AbstractAjpProcessor<Socket> {
             return false;
         }
 
-        bodyMessage.getBytes(bodyBytes);
+        bodyMessage.getBodyBytes(bodyBytes);
         empty = false;
         return true;
     }