Skip to content

Commit 2a109b0

Browse files
authored
Extract check for assembly marker (#3038)
***NO_CI***
1 parent 9d8ffca commit 2a109b0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/CLR/Core/TypeSystem.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,19 +1364,32 @@ HRESULT CLR_RT_TypeDescriptor::ExtractTypeIndexFromObject(const CLR_RT_HeapBlock
13641364
//
13651365
static const char c_MARKER_ASSEMBLY_V1[] = "NFMRK1";
13661366

1367+
bool CLR_RECORD_ASSEMBLY::ValidateMarker() const
1368+
{
1369+
NATIVE_PROFILE_CLR_CORE();
1370+
1371+
// compare the marker
1372+
return memcmp(marker, c_MARKER_ASSEMBLY_V1, sizeof(c_MARKER_ASSEMBLY_V1)) == 0;
1373+
}
1374+
13671375
bool CLR_RECORD_ASSEMBLY::GoodHeader() const
13681376
{
13691377
NATIVE_PROFILE_CLR_CORE();
13701378
CLR_RECORD_ASSEMBLY header = *this;
13711379
header.headerCRC = 0;
13721380

13731381
if (SUPPORT_ComputeCRC(&header, sizeof(header), 0) != this->headerCRC)
1382+
{
1383+
// check for a wrong version of the marker
13741384
return false;
1385+
}
13751386

13761387
if (this->stringTableVersion != c_CLR_StringTable_Version)
1388+
{
13771389
return false;
1390+
}
13781391

1379-
return memcmp(marker, c_MARKER_ASSEMBLY_V1, sizeof(c_MARKER_ASSEMBLY_V1)) == 0;
1392+
return ValidateMarker();
13801393
}
13811394

13821395
bool CLR_RECORD_ASSEMBLY::GoodAssembly() const

src/CLR/Include/nanoCLR_Types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,7 @@ struct CLR_RECORD_ASSEMBLY
10111011

10121012
bool GoodHeader() const;
10131013
bool GoodAssembly() const;
1014+
bool ValidateMarker() const;
10141015

10151016
#if defined(VIRTUAL_DEVICE)
10161017
void ComputeCRC();

0 commit comments

Comments
 (0)