Skip to content

Handle short reads when loading archive contents - #703

Open
Illustar0 wants to merge 2 commits into
Mutagen-Modding:devfrom
Illustar0:fix/archive-short-reads
Open

Illustar0 wants to merge 2 commits into
Mutagen-Modding:devfrom
Illustar0:fix/archive-short-reads

Conversation

@Illustar0

@Illustar0 Illustar0 commented Oct 2, 2026 •

Copy link
Copy Markdown

Fixes several CA2022 warnings by replacing single Read calls with ReadExactly when reading BA2 and BSA payloads.

This also fixes a potential short-read bug. It should be fairly rare in practice, as it only occurs when the underlying stream returns fewer bytes than requested before reaching EOF, but Stream.Read does allow this behavior.

Assuming short reads were never intended here, this does not change the behavior of successful reads.

- Read complete BA2 and BSA payloads with ReadExactly
- Correct the same read assumption in the existing BSA stream test
- Reuse the BSA fixture and add general-file and texture BA2 fixtures
- Verify complete payloads when streams return at most two bytes

This branch has not been deployed

No deployments
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