Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

[release/3.0] Fix BinaryReader.ReadChars for fragmented Streams (#26324) #26356

Merged
merged 1 commit into from
Aug 26, 2019

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Aug 24, 2019

Ports #26324 to 3.0

Fixes dotnet/corefx#40455

Description

BinaryReader.ReadChars may read more bytes than required from the underlying stream if the stream contain non-ASCII characters. It corrupts the data read by any subsequent BinaryReader.Read operation. The same bug was fixed in .NET Framework in 2010. The fix was accidentally removed during unification of BCL code between .NET Core and .NET Native.

Customer Impact

The bug was customer-reported as a regression of previous BinaryReader.ReadChars behavior. This API is used by ~7% of apps according to apisof.net.

Regression?

Yes, between .NET Core 2.2 (and earlier) and .NET Core 3.0.

Risk

Low. The fix is essentially adding back the previous code, with extra comments and correctness fix for UTF-16 encoding.

…et#26324)

BinaryReader.ReadChars incorrectly read more than necessary from the underlying Stream when multi-byte characters straddled the read chunks.

Fixes https://github.com/dotnet/corefx/issues/40455
@jkotas jkotas merged commit 654cd7e into dotnet:release/3.0 Aug 26, 2019
@jkotas jkotas deleted the corefx-40455-release-3.0 branch August 26, 2019 15:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants