Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-2534

SSLTransportLayer does not handle buffer overflow correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.9.0.0
    • 0.9.0.0
    • network
    • None

    Description

      There are a couple of issues with the handling of buffer overflow in SSLTransportLayer.

      1. netWriteBuffer is flipped immediately after wrap(), leaving the data ready for writing onto the socket channel. If netWriteBuffer is expanded because wrap() returns BUFFER_OVERFLOW, the expanded buffer needs to be un-flipped before expansion and flipped afterwards to leave the resulting buffer in the same state. The current implementation does not do this and hence the expanded buffer is not as expected.
      2. If handshakeUnwrap() returns a BUFFER_OVERFLOW because application buffer needs to be expanded, the current implementation expands the buffer and returns from the handshake() call. Since handshake data was already read from the network, this can result in the handshake never completing if no more data is received on the channel. handshakeUnwrap() should be invoked after application buffer expansion to process data that has already arrived.

      I will submit a PR with fixes for these along with unit tests which demonstrate these issues. I am not sure it is easy to trigger buffer overflow/underflow in a system test. Since these code paths are currently untested, unit tests which mock these scenarios may be useful.

      Attachments

        Issue Links

          Activity

            People

              rsivaram Rajini Sivaram
              rsivaram Rajini Sivaram
              Harsha Harsha
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: