From 21a7f5e1a6538214804fb6ed2dbbed28d025ed3b Mon Sep 17 00:00:00 2001 From: TalAloni Date: Mon, 13 Apr 2020 03:34:31 +0300 Subject: [PATCH] LoopbackServer.ReadAsync: Fixed data corruption bug (#34875) This caused the unused parts of the temp buffer to be copied to buffer, returning 0 to the caller instead of the actual data. This caused several tests to fail when targeting .NET Standard 2.0 --- src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs b/src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs index 48d75c8..97a93b3 100644 --- a/src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs +++ b/src/libraries/Common/tests/System/Net/Http/LoopbackServer.cs @@ -447,7 +447,7 @@ namespace System.Net.Test.Common int readLength = await _stream.ReadAsync(tempBuffer, 0, size).ConfigureAwait(false); if (readLength > 0) { - tempBuffer.AsSpan(readLength).CopyTo(buffer.Span.Slice(offset, size)); + tempBuffer.AsSpan(0, readLength).CopyTo(buffer.Span.Slice(offset, size)); } return readLength; -- 2.7.4