File tree Expand file tree Collapse file tree
src/TraceEvent/TraceUtilities Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -393,9 +393,13 @@ internal PEHeader(PEBufferedSlice slice)
393393
394394 m_sectionsOffset = m_ntHeaderOffset + sizeof ( IMAGE_NT_HEADERS ) + ntHdr . FileHeader . SizeOfOptionalHeader ;
395395
396- // Note: We don't validate that the span contains all section headers here.
397- // The PEFile constructor will check Header.PEHeaderSize and re-read with a larger buffer if needed.
398- // ReadOnlySpan bounds checking will catch any actual out-of-bounds reads when accessing sections.
396+ // Note: We don't validate that the span contains all section headers at this point.
397+ // This is intentional to support the progressive read pattern in PEFile:
398+ // 1. PEFile creates PEHeader with initial 1024-byte buffer
399+ // 2. PEFile checks Header.PEHeaderSize (which needs m_sectionsOffset + section count)
400+ // 3. If PEHeaderSize > buffer length, PEFile re-reads with correct size
401+ // 4. ReadOnlySpan bounds checking catches any out-of-bounds access when sections are actually read
402+ // This pattern allows PE files with large headers (>1024 bytes) to work correctly.
399403
400404 return ;
401405 ThrowBadHeader :
You can’t perform that action at this time.
0 commit comments