From 3d6c24ee9d71c1880d758e80bfb76cea490edf9d Mon Sep 17 00:00:00 2001 From: "nenad.pencic" Date: Thu, 3 May 2012 13:47:22 +0200 Subject: Add M570-loaders sanity-check in LCDriver Sanity-check of the header length and type before M570 Loader is sent to LCM, is added. ST-Ericsson ID: 431653 ST-Ericsson FOSS-OUT ID: STETL-FOSS-OUT-10204 Change-Id: I8469c02ab3fccb2bfd41abadbf10f1abf4ef4a90 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/57690 Tested-by: Vlatko STENKOSKI Tested-by: Aleksandar GASOSKI Reviewed-by: Vlatko PISTOLOV Tested-by: Vlatko PISTOLOV --- source/CEH/ProtromRpcInterface.h | 3 +++ source/LCDriverMethods.cpp | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) 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 @@ /// /// PROTROM command definitions. /// + +#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. -- cgit v1.2.3