-
Notifications
You must be signed in to change notification settings - Fork 4.9k
HPACK decoder fixes #39907
HPACK decoder fixes #39907
Conversation
…tests. Add support for headers beyond "literal+literal without indexing".
src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HPack/DynamicTable.cs
Show resolved
Hide resolved
@@ -265,6 +270,7 @@ public void Decode(ReadOnlySpan<byte> data, bool endHeaders, HeaderCallback onHe | |||
case State.HeaderNameLengthContinue: | |||
if (_integerDecoder.Decode(b)) | |||
{ | |||
Debug.Assert(_integerDecoder.Value != 0, "HPACK integer decoder failed to stop an overlong 0."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "an overlong 0" mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
over long encoding. the integer 0 should take only a single byte, any more and IntegerDecoder
will throw an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still having trouble parsing this. By "over long", do you mean "too long" / "too many bytes"?
Not trying to nitpick, I just wouldn't know how to react if this assert failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's terminology that came to me via UTF-8 security issues and I'm realizing now that it may not be common knowledge. I will update the assert message with something else.
Overlong encoding means an integer was encoded in more bytes than was required. IntegerDecoder
does not allow this. The assert is there mostly as documentation that we don't need to check the 0 case on continuation bytes because it is prevented elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Wasn't familiar with the term. Thanks for the explanation.
/azp run |
Azure Pipelines successfully started running 4 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 4 pipeline(s). |
Can't seem to get a reliable CI run today. Guess I'll try later once everyone is asleep :). |
Are these changes to code from ASP.NET Core HPACK? Should they be mirrored in aspnetcore? // @Tratcher |
@JamesNK yes it looks like both of these fixes willy apply to the ASP.NET version. |
Ug, I spent all day today debugging that. Amusingly our fixes look identical. dotnet/aspnetcore#12782 |
/azp run |
Azure Pipelines successfully started running 4 pipeline(s). |
@stephentoub @dotnet/ncl any further review? CI still failing in unrelated places. This is not platform-specific code so I think we're okay there as one of the outerloop runs got through successfully. @dotnet/dnceng @ViktorHofer @safern can anything be done about this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@scalablecory - from a DncEng perspective, the only suspicious bit I see is the OSX legs where it seems the machines may not be properly interactively logged in with unlocked keychains; The other failures look like flaky tests (the system.net one hitting an HTTP Client timeout is classic flaky test behavior) or just a plain bug causing fact failure (FileSystemWatcher ones) I'm checking out some of the macs and will discuss with folks about this; I believe many of them were recently reimaged and configuration might be subtly affected. |
@scalablecory one more update; I don't see anything specifically wrong about the machines your OSX work ran on w.r.t. interactive login or keychains, but @ilyas1974 is going to take a peek as well later. Thanks for bringing this to our attention! |
Thanks @MattGal |
It doing some investigation, it appears that they way Apple addresses the Key Chain functionality changed between 10.11/12 and 10.13/14. The configuration directory within /Library/Keychain no longer exists (where the permissions were originally changed in previous versions). As there is nothing to modify permissions on, the changes that we previous used do not apply. |
/// </summary> | ||
NeverIndexed = 8 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a second implementation of hpack encoding, separate from the product implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I see, you consolidated existing test code, rather than writing it from scratch as part of this PR. Ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The product fix LGTM.
…. Fail fast with same exception message that HTTP1 uses. Resolves #39873. Partial port of dotnet#39907 from master.
We have been actively working on disabling/fixing flaky tests for quite some time. Our goal is to stabilize CI and rolling builds by end of the year latest. We have measurements in place that will help us achieve that goal. |
- Fix HPACK decoder failing inconsistently with 0-length header names. Fail fast with same exception message that HTTP1 uses. Resolves dotnet/corefx#39873. - Fix `DynamicTable` returning incorrect values or throwing exceptions when it wraps its ring buffer. Resolves dotnet/corefx#39656. - Moves HPACK encoder methods from `Http2LoopbackConnection` into their own class. - Implement all forms of header encodings in HPACK encoder. - Move a number of files where they belong into the ProductionCode folder in unit test project. Commit migrated from dotnet/corefx@b7e60c9
DynamicTable
returning incorrect values or throwing exceptions when it wraps its ring buffer. Resolves #39656.Http2LoopbackConnection
into their own class.