Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 59c3819

Browse files
committed
Throw better exception when chunk length is invalid.
1 parent 60feeb0 commit 59c3819

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Titanium.Web.Proxy/EventArguments/LimitedStream.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Threading.Tasks;
55
using StreamExtended;
66
using StreamExtended.Network;
7+
using Titanium.Web.Proxy.Exceptions;
78

89
namespace Titanium.Web.Proxy.EventArguments
910
{
@@ -60,7 +61,11 @@ private void getNextChunk()
6061
chunkHead = chunkHead.Substring(0, idx);
6162
}
6263

63-
int chunkSize = int.Parse(chunkHead, NumberStyles.HexNumber);
64+
if (!int.TryParse(chunkHead, NumberStyles.HexNumber, null, out int chunkSize))
65+
{
66+
throw new ProxyHttpException($"Invalid chunk length: '{chunkSize}'", null, null);
67+
}
68+
6469
bytesRemaining = chunkSize;
6570

6671
if (chunkSize == 0)

src/Titanium.Web.Proxy/Http2/Http2Helper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal static async Task SendHttp2(Stream clientStream, Stream serverStream, i
4141
{
4242
var clientSettings = new Http2Settings();
4343
var serverSettings = new Http2Settings();
44-
;
44+
4545
var sessions = new ConcurrentDictionary<int, SessionEventArgs>();
4646

4747
// Now async relay all server=>client & client=>server data

0 commit comments

Comments
 (0)