Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-106

Link headers are not processed correctly

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Blocker
    • Resolution: Done
    • Affects Version/s: 1.0.0.Beta13
    • Fix Version/s: 1.0.0.Beta14
    • Component/s: Servlet
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      See attached demonstrator

      Show
      See attached demonstrator

      Description

      The undertow servlet request handler is not processing Link headers correctly. When I try to read the Link header undertow gives me the value corresponding to a different header name.

      The problem is that io.undertow.util.HeaderMap#getOrCreateEntry() hashes different header names into the same entry in its internal table. I have attached an example to demonstrate the issue, in it I send two headers with the names "Link" and "Rest". These strings just happen to hash to the same slot:

      final int hc = headerName.hashCode();
      final int idx = hc & (table.length - 1); // table.length is 16
      

      So calling request.getHeaders() (on an instance of io.undertow.servlet.spec.HttpServletRequestImpl) for header "Link" or "Rest" return the same value regardless of what the original headers were.

      The problem was not pressent in wildfly commit https://github.com/wildfly/wildfly/commit/fcb5355be422c7a838b7d05264ea231bf4ab2579 and we first noticed it in https://github.com/wildfly/wildfly/commit/9a3b000767c018a681a4858a84aae20a0b8c7310

      And the diff between the two is: https://github.com/wildfly/wildfly/compare/fcb5355be422c7a838b7d05264ea231bf4ab2579...9a3b000767c018a681a4858a84aae20a0b8c7310

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  swd847 Stuart Douglas
                  Reporter:
                  mmusgrov Michael Musgrove
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: