Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for malformed utf8 sequence #47

Merged
merged 10 commits into from
Mar 31, 2020

Conversation

R-maan
Copy link
Contributor

@R-maan R-maan commented Jan 11, 2020

Issue #36 :

Description of changes:
If StreamReader.Read() returns -1 while the stream still has bytes, an exception will be thrown as the stream cannot be parsed as a valid stream,

_streamReader = new StreamReader(inputStream, encoding);
_unreadStack = new Stack<int>();
remainingChars = inputStream.Length;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like not all implementations of Stream will support Length: https://docs.microsoft.com/en-us/dotnet/api/system.io.stream.length?view=netframework-4.8#System_IO_Stream_Length

Is there a way to implement this fix without using Stream.Length?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the pull request as we discussed.
If an implementation does not support Length property, there won't be any check for short sequences.

Created issue #101 to keep track of this.

@R-maan R-maan force-pushed the Fix-Short_UTF8-Sequence branch from 2d691d2 to 145a38b Compare March 30, 2020 20:58
@tgregg tgregg merged commit 89edf02 into amazon-ion:master Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants