From 78bc1e4c0919a7bcbdc90f1db45a22e4b31fdfbe Mon Sep 17 00:00:00 2001 From: "John D. Bruner" Date: Tue, 20 Aug 2024 20:34:26 -0700 Subject: [PATCH] decode ATS if present (ISO 14443-4 card) --- src/devices/Pn532/Pn532.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/devices/Pn532/Pn532.cs b/src/devices/Pn532/Pn532.cs index f63f3c9fa3..16de9962ae 100644 --- a/src/devices/Pn532/Pn532.cs +++ b/src/devices/Pn532/Pn532.cs @@ -575,12 +575,14 @@ private bool SetParameters(ParametersFlags parametersFlags) nfcId[i] = toDecode[5 + i]; } - if ((5 + nfcId.Length) > toDecode.Length) + if ((5 + nfcId.Length) < toDecode.Length) { + // The first byte of the ATS is the length, + // which includes itself. ats = new byte[toDecode[5 + nfcId.Length]]; for (int i = 0; i < ats.Length; i++) { - ats[i] = toDecode[6 + nfcId.Length + i]; + ats[i] = toDecode[5 + nfcId.Length + i]; } }