-
Couldn't load subscription status.
- Fork 10.5k
Closed
Labels
area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Microsoft.Net.Http.Headers.SetCookieHeaderValue.TryParse throws System.ArgumentOutOfRangeException if Max-Age value is greater than TimeSpan max seconds which is 922337203685.
Expected Behavior
Microsoft.Net.Http.Headers.SetCookieHeaderValue.TryParse returns false and do not throw any exceptions.
Steps To Reproduce
https://github.com/SharanovPavel/setcookieheadervalue-tryparse-overflow-repro
Exceptions (if any)
Unhandled exception. System.ArgumentOutOfRangeException: TimeSpan overflowed because the duration is too long.
at System.TimeSpan.FromSeconds(Int64 seconds)
at Microsoft.Net.Http.Headers.SetCookieHeaderValue.GetSetCookieLength(StringSegment input, Int32 startIndex, SetCookieHeaderValue& parsedValue)
at Microsoft.Net.Http.Headers.GenericHeaderParser`1.GetParsedValueLength(StringSegment value, Int32 startIndex, T& parsedValue)
at Microsoft.Net.Http.Headers.BaseHeaderParser`1.TryParseValue(StringSegment value, Int32& index, T& parsedValue)
at Microsoft.Net.Http.Headers.SetCookieHeaderValue.TryParse(StringSegment input, SetCookieHeaderValue& parsedValue)
.NET Version
9.0.203
Anything else?
Microsoft.Net.Http.Headers version: 9.0.4
Copilot
Metadata
Metadata
Assignees
Labels
area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions