hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject [3/3] httpcomponents-core git commit: HTTPCORE-472: Fixed problem with blocking message parsers incorrectly throwing "Maximum line length limit exceeded" exception in some corner cases
Date Thu, 15 Jun 2017 13:25:08 GMT
HTTPCORE-472: Fixed problem with blocking message parsers incorrectly throwing "Maximum line
length limit exceeded" exception in some corner cases


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/09d65b9b
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/09d65b9b
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/09d65b9b

Branch: refs/heads/master
Commit: 09d65b9b3e4aefe9c36b1a5ee6b8d6944e411302
Parents: d7768b2
Author: Oleg Kalnichevski <olegk@apache.org>
Authored: Thu Jun 15 13:30:24 2017 +0200
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Thu Jun 15 15:21:05 2017 +0200

----------------------------------------------------------------------
 .../hc/core5/http/impl/io/SessionInputBufferImpl.java    |  2 +-
 .../hc/core5/http/impl/io/TestSessionInOutBuffers.java   | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/09d65b9b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
index d5bd31e..5e8c03d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
@@ -252,7 +252,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer {
 
             if (this.maxLineLen > 0) {
                 final int currentLen = this.linebuffer.length()
-                        + (pos > 0 ? pos : this.bufferlen) - this.bufferpos;
+                        + (pos >= 0 ? pos : this.bufferlen) - this.bufferpos;
                 if (currentLen >= this.maxLineLen) {
                     throw new MessageConstraintException("Maximum line length limit exceeded");
                 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/09d65b9b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
index 2e68a20..f532c81 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
@@ -438,6 +438,17 @@ public class TestSessionInOutBuffers {
         }
     }
 
+    @Test //HTTPCORE-472
+    public void testLineLimit3() throws Exception {
+        final String s = "012345678\r\nblaaaaaaaaaaaaaaaaaah";
+        final byte[] tmp = s.getBytes(StandardCharsets.US_ASCII);
+        final SessionInputBuffer inbuffer1 = new SessionInputBufferImpl(128);
+        final ByteArrayInputStream inputStream = new ByteArrayInputStream(tmp);
+        final CharArrayBuffer chbuffer = new CharArrayBuffer(16);
+        inbuffer1.readLine(chbuffer, inputStream);
+        Assert.assertEquals("012345678", chbuffer.toString());
+    }
+
     @Test
     public void testReadLineFringeCase1() throws Exception {
         final String s = "abc\r\n";


Mime
View raw message