Snap for 7196288 from a009f4e3894f1be5e1786356753b4a51662e17dd to rvc-qpr3-release

Change-Id: Iac7180164e5fd1cbba6dfa142f6228f2c9739f72
diff --git a/st21nfc/hal_wrapper.cc b/st21nfc/hal_wrapper.cc
index 4449d2d..f687189 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"
@@ -386,6 +387,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],