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

order in which read_from_container() is called can fail read. #21

Open
Jeremiah-Griffin opened this issue Apr 17, 2022 · 1 comment
Open

Comments

@Jeremiah-Griffin
Copy link

if read_from_container(&mut bufreader) is called sometime after the read_to_end() has been called on the same File, read_from_container() will always fail with error InvalidFormat("Unknown image format")

The mitigation is to place the read_from_container() before the read_to_end() and to try_clone() the File when passing its reader to the read_from_container().

I have only tested this on Windows 10. All versions 0.5.x and 0.4 seem to be affected. I have not tested on earlier versions of the library.

I am unsure if this behavior is known, but it should be documented as the operation fails otherwise silently aside from the aforementioned error which is incorrect; the data on disk is not corrupt, just the handle.

@kamadak
Copy link
Owner

kamadak commented Sep 6, 2022

I may be able to help you if your high-level goal is described.
Anyway, I will comment on the behavior.

If you have called read_to_end(), it is no surprise that read_from_container() will fail, because there is no data left.

Your "mitigation" does not make sense to me. Even if try_clone() is used, read_from_container() advances the underlying file pointer, so read_to_end() will not read what you expect, I guess.

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

No branches or pull requests

2 participants