jira-importer opened a new issue, #976: URL: https://github.com/apache/httpcomponents-core/issues/976
**[Artem Nakonechnyy](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=anakonechny)** opened **[HTTPCORE-472](https://issues.apache.org/jira/browse/HTTPCORE-472?redirect=false)** and commented the error is in org.apache.http.impl.io.SessionInputBufferImpl#readLine(org.apache.http.util.CharArrayBuffer) ``` if (maxLineLen > 0) { final int currentLen = this.linebuffer.length() + (pos > 0 ? pos : this.bufferlen) - this.bufferpos; if (currentLen >= maxLineLen) { throw new MessageConstraintException("Maximum line length limit exceeded"); } } ``` If LF chanced to be at the beginning of the buffer, `currentLen` is calculated incorrectly. It should be `this.linebuffer.length() + pos - this.bufferpos`, so, effectively `this.linebuffer.length() + 0 - 0`. E.g. if maxLineLen=10000, buffer.length=8192 (the default setting), a line is 9000, then it doesn't fit the buffer, thus it's 1st part is read into `linebuffer`, 2nd part is read into `buffer`. If the 9000 line's terminating LF chances to be the 1st char of that buffer, and after that line it follows more header data, say, exceeding 8192 bytes - then the code calculates `currentLen = linebuffer.length() + bufferlen - bufferpos = 9000+ 8192 - 0` > 10000, while actual line length is just 9000. I think the fix is to replace `(pos > 0 ? pos : this.bufferlen)` to `(pos > -1 ? pos : this.bufferlen)` --- **Affects:** 4.4.6 **Backported to:** [4.4.7](https://github.com/apache/httpcomponents-core/milestone/44?closed=1) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
