Fix heap buffer overflow in nfa_t4tnfcee_store_rx_buf

The NDEF-NFCEE feature lets Android read an NDEF file stored on the eSE/UICC.
nfa_t4tnfcee_store_rx_buf() drops the received APDU if its length exceeds the
remaining buffer size. However, this causes the read operation to be truncated,
which might lead to incomplete NDEF data being processed.

To fix this and prevent the heap buffer overflow, this patch clamps the copy
size to the remaining available buffer size rather than dropping the whole
packet, ensuring that valid data is preserved up to the allocated capacity.
Additionally, this prevents a status overwrite in WAIT_READ_FILE that could
have masked the failure.

Bug: 503545851
Test: atest libnfc-nci-tests:NfaNfceeActTest
Flag: EXEMPT BUGFIX
(cherry picked from commit c51a26973ba862b787b964e0786670507ee3cce7)
Cherrypick-From: https://googleplex-android-review.googlesource.com/q/commit:75533f55267b044e1b12e8e40c08d1b4a3d24b4e
Merged-In: Ie601a3726a0e9e182ce3b759db2873500afb0bd7
Change-Id: Ie601a3726a0e9e182ce3b759db2873500afb0bd7
2 files changed