Author: norman
Date: Wed Feb 24 11:37:29 2010
New Revision: 915758
URL: http://svn.apache.org/viewvc?rev=915758&view=rev
Log:
Correct handling of line limits.. I had a bad understanding of how the
ProtocolEncoder stuff work before
Modified:
james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java
james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java
Modified:
james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java?rev=915758&r1=915757&r2=915758&view=diff
==============================================================================
---
james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java
(original)
+++
james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/CRLFTerminatedLineDecoder.java
Wed Feb 24 11:37:29 2010
@@ -27,7 +27,7 @@
/**
* LineDecoder which buffer the input till a CRLF was found. It will throw an
exception if a maxlinelength was
- * reached to prevent an DOS attack. The default is 2048 chars (including
CRLF).
+ * reached to prevent an DOS attack. The default is 20480 chars (including
CRLF).
*
*/
public class CRLFTerminatedLineDecoder extends CumulativeProtocolDecoder {
@@ -69,16 +69,9 @@
// Now find the first CRLF in the buffer.
byte previous = 0;
- if (maxLineLength != -1 && in.remaining() > maxLineLength) {
-
- // clear the buffer before throw exception
- in.clear();
-
- throw new LineLengthExceededException(maxLineLength,
in.remaining());
- }
+ int count = 0;
while (in.hasRemaining()) {
byte current = in.get();
-
if (previous == '\r' && current == '\n') {
// Remember the current position and limit.
@@ -104,6 +97,16 @@
return true;
}
+ count++;
+
+ if (maxLineLength != -1 && count > maxLineLength) {
+
+ // clear the buffer before throw exception
+ in.clear();
+
+ throw new LineLengthExceededException(maxLineLength);
+ }
+
previous = current;
}
Modified:
james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java
URL:
http://svn.apache.org/viewvc/james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java?rev=915758&r1=915757&r2=915758&view=diff
==============================================================================
---
james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java
(original)
+++
james/server/trunk/mina-socket/src/main/java/org/apache/james/socket/mina/codec/LineLengthExceededException.java
Wed Feb 24 11:37:29 2010
@@ -30,7 +30,7 @@
@SuppressWarnings("serial")
public class LineLengthExceededException extends IOException{
- public LineLengthExceededException(int limit, int actualLength) {
- super("Line length limit exceeded. Limit =>" + limit + " Actual=>" +
actualLength);
+ public LineLengthExceededException(int limit) {
+ super("Line length limit " + limit + " exceeded");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]