Compare ls script hash without execution status
am: 24283c2fc9
Change-Id: I0cf2d3ab87a063894eaf10130e23b5a9bb330916
diff --git a/ls_client/inc/LsLib.h b/ls_client/inc/LsLib.h
index b7f8329..1bb9214 100755
--- a/ls_client/inc/LsLib.h
+++ b/ls_client/inc/LsLib.h
@@ -23,6 +23,8 @@
#include "LsClient.h"
#include "phNxpEse_Api.h"
+extern const size_t HASH_DATA_LENGTH;
+
typedef struct Lsc_ChannelInfo {
uint8_t channel_id;
bool isOpend;
diff --git a/ls_client/src/LsClient.cpp b/ls_client/src/LsClient.cpp
index 50ea3d1..05a24ba 100755
--- a/ls_client/src/LsClient.cpp
+++ b/ls_client/src/LsClient.cpp
@@ -194,7 +194,7 @@
if ((lsHashStatus == LSCSTATUS_SUCCESS) &&
(lsHashInfo.readHashLen == HASH_DATA_LENGTH) &&
(0 == memcmp(lsHashInfo.lsScriptHash, lsHashInfo.readBuffHash,
- HASH_DATA_LENGTH)) &&
+ HASH_DATA_LENGTH - 1)) &&
(lsHashInfo.readBuffHash[HASH_STATUS_INDEX] == LS_DOWNLOAD_SUCCESS)) {
ALOGD_IF(ese_debug_enabled, "%s LS Loader sript is already installed \n",
__func__);
diff --git a/ls_client/src/LsLib.cpp b/ls_client/src/LsLib.cpp
index eba3183..9dac201 100755
--- a/ls_client/src/LsLib.cpp
+++ b/ls_client/src/LsLib.cpp
@@ -2049,9 +2049,13 @@
ALOGD_IF(ese_debug_enabled, "%s: rspApdu.len : %u", __func__,
rspApdu.len);
*readHashLen = rspApdu.len - 2;
- memcpy(hash, rspApdu.p_data, rspApdu.len);
-
- lsStatus = LSCSTATUS_SUCCESS;
+ if (*readHashLen <= HASH_DATA_LENGTH) {
+ memcpy(hash, rspApdu.p_data, *readHashLen);
+ lsStatus = LSCSTATUS_SUCCESS;
+ } else {
+ ALOGE("%s:Invalid LS HASH data received", __func__);
+ lsStatus = LSCSTATUS_FAILED;
+ }
} else {
if ((rspApdu.p_data[rspApdu.len - 2] == 0x6A) &&
(rspApdu.p_data[rspApdu.len - 1] == 0x86)) {