mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
Pre-checking stream.Length before reading is racy (the stream can shrink between check and read) and not every stream knows its length ahead of time. Instead, catch EndOfStreamException at each read: a stream too short for the magic is passed through as not-XALZ, and a truncated header or payload after a confirmed magic is rejected as InvalidDataException. stream.Length remains only a sizing hint for the payload buffer. Assisted-by: Claude:claude-fable-5:Claude Code