From cb1d0f3956f284e6f34901e32463284cf7fc5bc7 Mon Sep 17 00:00:00 2001 From: Cesar Blum Silveira Date: Fri, 12 May 2017 16:04:38 -0700 Subject: [PATCH] Prevent infinite loop in PipelineExtensions.PeekAsyncAwaited() (#1827). --- .../Internal/Http/PipelineExtensions.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/PipelineExtensions.cs b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/PipelineExtensions.cs index d9b27dfbbf..1fe8107209 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/PipelineExtensions.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http/PipelineExtensions.cs @@ -40,7 +40,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http } finally { - pipelineReader.Advance(result.Buffer.Start, result.Buffer.Start); + pipelineReader.Advance(result.Buffer.Start, result.Buffer.IsEmpty + ? result.Buffer.End + : result.Buffer.Start); } input = pipelineReader.ReadAsync(); } @@ -68,7 +70,9 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http } finally { - pipelineReader.Advance(result.Buffer.Start, result.Buffer.Start); + pipelineReader.Advance(result.Buffer.Start, result.Buffer.IsEmpty + ? result.Buffer.End + : result.Buffer.Start); } readingTask = pipelineReader.ReadAsync(); @@ -325,4 +329,4 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http return bytes; } } -} \ No newline at end of file +}