Uploaded image for project: 'HttpComponents HttpCore'
  1. HttpComponents HttpCore
  2. HTTPCORE-285

Handle invalid HTTP traffic

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 4.1.2
    • Fix Version/s: None
    • Component/s: HttpCore
    • Labels:
      None

      Description

      Invalid HTTP responses are not handled well and can cause OutOfMemoryError errors.

      Most errors can probably be addressed by limiting the length when reading a line.

      For example:

      cat /dev/zero | nc -l 1234 # run a server that spews invalid data
      java org.apache.http.examples.client.ClientWithResponseHandler # modified example to connect to above server

      Result:

      executing request http://localhost:1234/
      Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
      at org.apache.http.util.ByteArrayBuffer.expand(ByteArrayBuffer.java:59)
      at org.apache.http.util.ByteArrayBuffer.append(ByteArrayBuffer.java:89)
      at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:261)
      at org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:98)
      at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:252)
      at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:281)
      at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:247)
      at org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:219)
      at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:298)
      at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
      at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:645)
      at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:464)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:941)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:919)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:910)
      at org.apache.http.examples.client.ClientWithResponseHandler.main(ClientWithResponseHandler.java:52)

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sjones4 Steve Jones
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: