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

Block parsing allows a few (<4) bytes of junk data after the last block #1547

Open
braingram opened this issue May 15, 2023 · 1 comment
Open

Comments

@braingram
Copy link
Contributor

This is likely a bug but the following test relies on this behavior:
https://github.com/asdf-format/asdf/blob/3d46a99c69a06dcb806606190cc7815e15483a3c/asdf/_tests/test_array_blocks.py#L445C5-L465

Reading files with a streamed block also depends on this behavior as fd.fast_forward(-1) results in a seek to the last byte in the file (not the end of the file) so reading the input file after the streamed block is encountered results in reading the last byte in the stream.

@braingram
Copy link
Contributor Author

This is partially addressed in #1537 which introduced a warning:

asdf/asdf/_block/reader.py

Lines 142 to 145 in 9680015

# if these are non-0 bytes issue a warning that the file
# is likely corrupt
msg = f"Read invalid bytes {buff!r} after blocks, your file might be corrupt"
warnings.warn(msg, AsdfWarning)

However a more thorough set of tests are needed.

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

1 participant