Skip to content

okhttp: fix HPACK reader bug #4276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 28, 2018
Merged

Conversation

ericgribkoff
Copy link
Contributor

This fixes #4261.

Our OkHttp HPACK decoder was improperly tossing out the already-parsed header fields when it resized the dynamic table. From the HPACK RFC section 3.1:

Once a header field is decoded and added to the reconstructed header list, the header field cannot be removed. A header field added to the header list can be safely passed to the application.

This bug appears to have also been present on the OkHttp 2.7 upstream branch.

This was caught in #4261 by interop with nginx, which was setting the max dynamic table size to 0. When considering adding an item to the table and finding that item exceeds the max dynamic table size,
OkHttp clears the dynamic table. This is the correct behavior, but it was also deleting the already processed header fields. The HTTP status code was among the fields that was erroneously thrown away, triggering the exception in #4261.

The only substantive change in this PR is the deletion of line 167 (headerList.clear()) in the clearDynamicTable() method. The other changes are just two variable renames to make it clear that the values tracked in the dynamic table are not the same as the already-processed header values to return to the application in headerList.

@ericgribkoff
Copy link
Contributor Author

@ejona86 I locally ran the OkHttp 2.7 tests (https://github.com/square/okhttp/blob/okhttp_27/okhttp-tests/src/test/java/com/squareup/okhttp/internal/framed/HpackTest.java) on this change, and also added a new test case which verifies the fix for this bug. It seems like it might be time to add (at least) these tests to our forked codebase; what do you think?

@ericgribkoff ericgribkoff requested a review from ejona86 March 27, 2018 16:37
@ejona86 ejona86 added the TODO:release blocker Issue/PR is important enough to delay the release. Removed after release issues resolved label Mar 27, 2018
@ericgribkoff ericgribkoff removed the TODO:release blocker Issue/PR is important enough to delay the release. Removed after release issues resolved label Mar 27, 2018
@ericgribkoff
Copy link
Contributor Author

@ejona86 Split apart into 4 commits (let me know if that's a bit excessive). The first commit contains the actual fix and is backported in #4277

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 commits is great

@ericgribkoff ericgribkoff added the kokoro:force-run Add this label to a PR to tell Kokoro to re-run all tests. Not generally necessary label Mar 28, 2018
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to a PR to tell Kokoro to re-run all tests. Not generally necessary label Mar 28, 2018
ericgribkoff added a commit that referenced this pull request Mar 28, 2018
Backport of the first commit of #4276.
@ejona86
Copy link
Member

ejona86 commented Mar 28, 2018

Could this be merged? I'd like it in master before doing the release with the backport.

@ericgribkoff
Copy link
Contributor Author

Fixed the third commit (needed bazel build file update for new path), will merge on green

@ericgribkoff ericgribkoff merged commit 77e3b97 into grpc:master Mar 28, 2018
@ericgribkoff ericgribkoff deleted the okhttp_hpack branch March 28, 2018 21:53
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ok http read header error
3 participants