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

Erratic behavior if supplied InputStream does not support mark operations #3

Open
cjritola opened this issue Feb 12, 2024 · 0 comments
Assignees
Labels

Comments

@cjritola
Copy link
Member

Parsers using expect...() may exhibit erratic behavior if the supplied InputStream does not support mark operations. The Parser class uses mark operations, however when not supported, said mark operations fail silently and the Parser continues without properly rewinding (resetting), resulting in bad input data which causes the Parser to fail to properly parse the stream.

This is most notable in BINFile, where resets are heavily depended upon.

Workaround is to wrap the passed InputStream into a BufferedInputStream, preferrably with a buffer at least large enough as the largest expect...() sequence. In my experience, 4096 bytes is plenty.

An initial fix would be to have the Parser require that the InputStream supports mark operations, verify that mark is supported, or throw an exception on verification fail.

@cjritola cjritola added the bug label Feb 12, 2024
@cjritola cjritola self-assigned this Feb 12, 2024
@cjritola cjritola changed the title Erratic behavior is supplied InputStream does not support mark operations Erratic behavior if supplied InputStream does not support mark operations Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant