Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2021-03-17 16:35:31 +0300
committerGitHub <noreply@github.com>2021-03-17 16:35:31 +0300
commitade51040b054a2f97fe795ef89ca1d59756e6ccb (patch)
tree7f8a56f609ae48eb12acbc43d1b481acc78e8163 /src
parentac5c33defa6a9983e85ce8bf0be352cb09f5b8eb (diff)
Big-endian fixes for ilasm/ildasm (#49685)
* Add byte swap when accessing PublicKeyBlob in AsmMan::EndAssembly * Fix access beyond end of pszString in DumpUnicodeString * Remove unneccessary assert in _FillMDDefaultValue
Diffstat (limited to 'src')
-rw-r--r--src/coreclr/ilasm/asmman.cpp2
-rw-r--r--src/coreclr/ildasm/dis.cpp4
-rw-r--r--src/coreclr/md/runtime/mdinternalro.cpp3
3 files changed, 4 insertions, 5 deletions
diff --git a/src/coreclr/ilasm/asmman.cpp b/src/coreclr/ilasm/asmman.cpp
index 55fbeb06de7..63d9b3694ba 100644
--- a/src/coreclr/ilasm/asmman.cpp
+++ b/src/coreclr/ilasm/asmman.cpp
@@ -456,7 +456,7 @@ void AsmMan::EndAssembly()
// into the public key buffer).
if (m_sStrongName.m_cbPublicKey >= sizeof(PublicKeyBlob) &&
(offsetof(PublicKeyBlob, PublicKey) +
- ((PublicKeyBlob*)m_sStrongName.m_pbPublicKey)->cbPublicKey) == m_sStrongName.m_cbPublicKey)
+ VAL32(((PublicKeyBlob*)m_sStrongName.m_pbPublicKey)->cbPublicKey)) == m_sStrongName.m_cbPublicKey)
m_sStrongName.m_fFullSign = FALSE;
else
m_sStrongName.m_fFullSign = TRUE;
diff --git a/src/coreclr/ildasm/dis.cpp b/src/coreclr/ildasm/dis.cpp
index 91f37422d76..8ca544ebd10 100644
--- a/src/coreclr/ildasm/dis.cpp
+++ b/src/coreclr/ildasm/dis.cpp
@@ -741,8 +741,8 @@ char* DumpUnicodeString(void* GUICookie,
if((size_t)pszString & (sizeof(WCHAR)-1))
#endif
{
- L = (cbString+1)*sizeof(WCHAR);
- pszStringCopy = new WCHAR[cbString+1];
+ L = cbString*sizeof(WCHAR);
+ pszStringCopy = new WCHAR[cbString];
memcpy(pszStringCopy, pszString, L);
pszString=pszStringCopy;
}
diff --git a/src/coreclr/md/runtime/mdinternalro.cpp b/src/coreclr/md/runtime/mdinternalro.cpp
index 327eb8648a7..7f8005a1faf 100644
--- a/src/coreclr/md/runtime/mdinternalro.cpp
+++ b/src/coreclr/md/runtime/mdinternalro.cpp
@@ -3323,9 +3323,8 @@ HRESULT _FillMDDefaultValue(
#if BIGENDIAN
{
// We need to allocate and swap the string if we're on a big endian
+ // This allocation will be freed by the MDDefaultValue destructor.
pMDDefaultValue->m_wzValue = new WCHAR[(cbValue + 1) / sizeof (WCHAR)];
- _ASSERTE(FALSE); // Nothing ever free's this newly allocated array. Inserting assert so that if we ever actually
- // use this code path, we'll fix it then. (Don't want to fix something I can't test.)
IfNullGo(pMDDefaultValue->m_wzValue);
memcpy(const_cast<WCHAR *>(pMDDefaultValue->m_wzValue), pValue, cbValue);
_ASSERTE(cbValue % sizeof(WCHAR) == 0);