Fix partial reads on compressed data #27

Merged
Rob-Hague merged 1 commits from partialread into master 2025-01-09 16:57:44 +00:00
Rob-Hague commented 2025-01-01 13:04:56 +00:00 (Migrated from github.com)

Hi, thanks for the library! I found this issue via inspection, in practice it is probably less likely when reading a FileStream due to buffering:

When reading a compressed data element, the call to reader.BaseStream.Read may read fewer bytes than expected. Using reader.ReadBytes instead will get the correct number of bytes (unless EOF is reached, in which case the file is probably corrupt anyway).

For testing, use a wrapping stream which only reads one byte at a time. I just applied this on all the reader tests

Hi, thanks for the library! I found this issue via inspection, in practice it is probably less likely when reading a FileStream due to buffering: When reading a compressed data element, the call to `reader.BaseStream.Read` may read fewer bytes than expected. Using `reader.ReadBytes` instead will get the correct number of bytes (unless EOF is reached, in which case the file is probably corrupt anyway). For testing, use a wrapping stream which only reads one byte at a time. I just applied this on all the reader tests
mahalex commented 2025-01-09 16:57:03 +00:00 (Migrated from github.com)

Great! Thanks for your work!

Great! Thanks for your work!
Rob-Hague commented 2025-01-10 08:38:28 +00:00 (Migrated from github.com)

Thanks!

Thanks!
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mahalex/MatFileHandler#27
No description provided.