Skip to content

Commit fed2757

Browse files
Fix incorrect fread return value check in ilasm strong-name key loading (#121837)
**Summary:** This PR fixes a logic error in AsmMan::EndAssembly() that incorrectly treated a successful fread() call as a failure. The incorrect condition: ``` dwBytesRead = fread(m_sStrongName.m_pbPublicKey, 1, m_sStrongName.m_cbPublicKey, fp)) <= m_sStrongName.m_cbPublicKey) ``` causes the error branch to execute even when the full key file has been read successfully (dwBytesRead == m_sStrongName.m_cbPublicKey). This results in ilasm failing to read .snk key files when building TestILAssembly on Big Endian Systems. **Environment:** Architecture: s390x OS: Ubuntu Runtime : Mono cc: @uweigand @giritrivedi @saitama951
1 parent 5e7ef6b commit fed2757

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/coreclr/ilasm/asmman.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ void AsmMan::EndAssembly()
437437
// Read the file into the buffer.
438438
size_t dwBytesRead;
439439

440-
if ((dwBytesRead = fread(m_sStrongName.m_pbPublicKey, 1, m_sStrongName.m_cbPublicKey, fp)) <= m_sStrongName.m_cbPublicKey) {
440+
if ((dwBytesRead = fread(m_sStrongName.m_pbPublicKey, 1, m_sStrongName.m_cbPublicKey, fp)) < m_sStrongName.m_cbPublicKey) {
441441
HRESULT hr = HRESULTFromErrno();
442442
MAKE_UTF8PTR_FROMWIDE(keySourceNameUtf8, ((Assembler*)m_pAssembler)->m_wzKeySourceName);
443443
report->error("Failed to read key file '%s': 0x%d\n",keySourceNameUtf8,hr);

0 commit comments

Comments
 (0)