Skip to content

Read module streams until complete - #589

Open
dajiaohuang wants to merge 1 commit into
0xd4d:masterfrom
dajiaohuang:fix-module-load-partial-stream-reads
Open

dajiaohuang wants to merge 1 commit into
0xd4d:masterfrom
dajiaohuang:fix-module-load-partial-stream-reads

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 19, 2026 •

Copy link
Copy Markdown

ModuleDefMD.Load(Stream) accepts a caller-owned stream and resets its position before loading. Stream.Read may legally return fewer bytes than requested before EOF, so a valid seekable stream that supplies partial reads currently fails with IOException. Loop until the declared length is read, retaining the existing EOF failure.\n\nValidated using a benign synthetic assembly compiled locally and a seekable wrapper that returns at most one byte per Read: the base implementation throws "Could not read all bytes from the stream"; the fix loads the module. The local runner/library build passed on .NET 6 / .NET 9. No third-party binaries were used.

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