DO NOT MERGE - Merge RQ3A.210605.005

Bug: 190855093
Merged-In: I489725b9da3f9e3eb47012073f9a72b2fbce50ba
Change-Id: I285168afbc93f8213d0faaab4ed07463a1e20958
diff --git a/1.2/StNfcService.cpp b/1.2/StNfcService.cpp
index a5b7b70..69f3dc1 100644
--- a/1.2/StNfcService.cpp
+++ b/1.2/StNfcService.cpp
@@ -53,7 +53,8 @@
       ALOGD("STReset Start");
       STEseReset fn = (STEseReset)dlsym(stdll, "boot_reset");
       if (fn) {
-        ALOGD("STReset Result=%d", fn());
+        int ret = fn();
+        ALOGD("STReset Result=%d", ret);
       }
     } else {
       ALOGE("%s not found, do nothing.", valueStr.c_str());
diff --git a/1.2/hal_st21nfc.cc b/1.2/hal_st21nfc.cc
index 67a421a..fb4f3c9 100644
--- a/1.2/hal_st21nfc.cc
+++ b/1.2/hal_st21nfc.cc
@@ -393,7 +393,8 @@
       STLOG_HAL_D("STReset Cold reset");
       STEseReset fn = (STEseReset)dlsym(stdll, "cold_reset");
       if (fn) {
-        STLOG_HAL_D("STReset Result=%d", fn());
+        int ret = fn();
+        STLOG_HAL_D("STReset Result=%d", ret);
       }
     } else {
       STLOG_HAL_D("%s not found, do nothing.", valueStr.c_str());
diff --git a/st21nfc/hal_wrapper.cc b/st21nfc/hal_wrapper.cc
index 799a8f2..d92b477 100644
--- a/st21nfc/hal_wrapper.cc
+++ b/st21nfc/hal_wrapper.cc
@@ -20,6 +20,7 @@
 #include <cutils/properties.h>
 #include <errno.h>
 #include <hardware/nfc.h>
+#include <log/log.h>
 #include <string.h>
 #include <unistd.h>
 #include "android_logmsg.h"
@@ -397,6 +398,14 @@
                             __func__);
               }
 
+              if (data_len < 9 || p_data[6] == 0 || p_data[6] < (data_len - 7)
+                  || p_data[6] > (sizeof(nciPropEnableFwDbgTraces) - 9)) {
+                if (confNeeded) {
+                  android_errorWriteLog(0x534e4554, "169328517");
+                  confNeeded = false;
+                }
+              }
+
               if (confNeeded) {
                 memcpy(nciPropEnableFwDbgTraces, nciHeaderPropSetConfig, 9);
                 memcpy(&nciPropEnableFwDbgTraces[10], &p_data[8],