Skip to content

Commit f2a38bf

Browse files
authored
Don't try to overrun the buffer in emitMetaData (#109086)
This should fix the System.BadImageFormatException failures in #108636 that were being caused by ilasm producing malformed DLLs in some cases.
1 parent 489a151 commit f2a38bf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/coreclr/md/ceefilegen/cceegen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ HRESULT CCeeGen::emitMetaData(IMetaDataEmit *emitter, CeeSection* section, DWORD
439439
IfFailGoto((HRESULT)metaStream->Seek(disp, STREAM_SEEK_SET, NULL), Exit);
440440
}
441441
ULONG metaDataLen;
442-
IfFailGoto((HRESULT)metaStream->Read(buffer, buffLen+1, &metaDataLen), Exit);
442+
IfFailGoto((HRESULT)metaStream->Read(buffer, buffLen, &metaDataLen), Exit);
443443

444444
_ASSERTE(metaDataLen <= buffLen);
445445

0 commit comments

Comments
 (0)