Skip to content

Improve file magic handling #1375

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonludlam
Copy link
Member

Before this change, the magic string was read by reading the number of bytes we're expecting to read based on our magic string. If ours happens to be a prefix of the real one (e.g. ours is 'odoc-3.1.0' and the real one is 'odoc-3.1.0-2-g12345789') then the check was succeeding and then the subsequent unmarshalling was failing.

This fixes that by writing the length too, so we always unmarshal the right length.

Before this change, the magic string was read by reading the number
of bytes we're expecting to read based on our magic string. If ours
happens to be a prefix of the real one (e.g. ours is
'odoc-3.1.0' and the real one is 'odoc-3.1.0-2-g12345789') then
the check was succeeding and then the subsequent unmarshalling was
failing.

This fixes that by writing the length too, so we always unmarshal
the right length.
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.

1 participant