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 infinite loop when reading truncated data #157

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

nirosys
Copy link
Contributor

@nirosys nirosys commented Feb 5, 2025

Issue #, if available: n/a

Description of changes:

This PR addresses an issue where an infinite loop could be triggered due to corrupted or truncated ion data.

Previous to this PR when retrieving bytes from the underlying input, RawBinaryReader did not check the return value of the call to Read. In the event that there was not enough bytes to return, Read would return 0 and the RawBinaryReader would get stuck in an infinite loop trying to read more data.

This PR adds the check of the return value and throws an UnexpectedEofException if the amount read is zero. A unit test to ensure this behavior was also added.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@nirosys nirosys marked this pull request as ready for review February 5, 2025 07:25
@nirosys nirosys merged commit 34a4f52 into amazon-ion:master Feb 5, 2025
2 checks passed
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