summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/CEH/ProtromRpcInterface.h3
-rw-r--r--source/LCDriverMethods.cpp13
2 files changed, 15 insertions, 1 deletions
diff --git a/source/CEH/ProtromRpcInterface.h b/source/CEH/ProtromRpcInterface.h
index 5f928fd..1c3cdb2 100644
--- a/source/CEH/ProtromRpcInterface.h
+++ b/source/CEH/ProtromRpcInterface.h
@@ -17,6 +17,9 @@
/// <summary>
/// PROTROM command definitions.
/// </summary>
+
+#define HEADER_A2_IDENTIFIER (0x0003BEBA)
+
typedef enum {
PROTROM_PDU_HEADER = 1,
PROTROM_PDU_PAYLOAD = 2,
diff --git a/source/LCDriverMethods.cpp b/source/LCDriverMethods.cpp
index 58e0783..7455ee4 100644
--- a/source/LCDriverMethods.cpp
+++ b/source/LCDriverMethods.cpp
@@ -2321,13 +2321,22 @@ int CLCDriverMethods::Do_PROTROM_DownloadLoader(const char *pchPath, int iPLOffs
size_t NumberOfPackets;
uint32 PayloadOffset;
uint32 LeftToSend;
+ uint8 *Header_p;
+ uint32 HeaderIdentifier = 0;
VERIFY_SUCCESS(IsMainThreadAlive());
VERIFY_SUCCESS(loaderFile.LoadFileData(pchPath));
/* coverity[tainted_data_return] */
loaderData = loaderFile.AllocateFileData(0, loaderFile.GetFileSize());
- VERIFY(0 != loaderData, loaderFile.GetError());
+ VERIFY(0 != loaderData, loaderFile.GetError());
+
+ Header_p = loaderData;
+ // Only version A2 type headers is supported. This is identfied with
+ // HEADER_A2_IDENTIFIER.
+ HeaderIdentifier = (Header_p[0] | (Header_p[1] << 8) | (Header_p[2] << 16) | (Header_p[3] << 24));
+
+ VERIFY((HeaderIdentifier == HEADER_A2_IDENTIFIER), E_LOADER_SEC_LIB_HEADER_VERIFICATION_FAILURE);
//Get header length.
temp = loaderData + iHLOffset;
@@ -2338,6 +2347,8 @@ int CLCDriverMethods::Do_PROTROM_DownloadLoader(const char *pchPath, int iPLOffs
temp = loaderData + iPLOffset;
PL = m_pSerialization->get_uint32_le(&temp);
+ VERIFY(((PL + HL_Real) == loaderFile.GetFileSize()), E_LOADER_SEC_LIB_HEADER_VERIFICATION_FAILURE);
+
VERIFY_SUCCESS(m_pProtromRpcFunctions->DoRPC_PROTROM_SendLoaderHeader(loaderData, HL_Real));
//Receive PROTROM command PDU: PROTROM_PDU_RESULT.