From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alisher Alikhodjaev <alisher@google.com>
Date: Tue, 22 Nov 2022 15:49:11 -0800
Subject: [PATCH] DO NOT MERGE OOBW in phNciNfc_MfCreateXchgDataHdr

Bug: 246932269
Test: Build ok
Change-Id: I4dcd18da8b5145e218d070414da8997aff181364
(cherry picked from commit 2e4dfa6c92de30907851914add6485f8b7920968)
Merged-In: I4dcd18da8b5145e218d070414da8997aff181364
---
 nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c b/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c
index 8e9399ef..8338bd34 100644
--- a/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c
+++ b/nci/jni/extns/pn54x/src/mifare/phNxpExtns_MifareStd.c
@@ -1561,6 +1561,12 @@ phNciNfc_MfCreateXchgDataHdr(phNciNfc_TransceiveInfo_t tTranscvInfo,
     NFCSTATUS   status = NFCSTATUS_SUCCESS;
     uint8_t     i = 0;
 
+    if (tTranscvInfo.tSendData.wLen > (MAX_BUFF_SIZE - 1))
+    {
+      android_errorWriteLog(0x534e4554, "246932269");
+      return NFCSTATUS_FAILED;
+    }
+
     buff[i++] = phNciNfc_e_MfRawDataXchgHdr;
     memcpy(&buff[i],tTranscvInfo.tSendData.pBuff,tTranscvInfo.tSendData.wLen);
     *buffSz = i + tTranscvInfo.tSendData.wLen;
