NFC: NCI: Fix max length of General Bytes in ATR_RES
authorJulien Lefrique <lefrique@marvell.com>
Tue, 2 Dec 2014 15:25:01 +0000 (16:25 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 2 Dec 2014 21:59:28 +0000 (22:59 +0100)
The maximum size of ATR_REQ and ATR_RES is 64 bytes.
The maximum number of General Bytes is calculated by
the maximum number of data bytes in the ATR_REQ/ATR_RES,
substracted by the number of mandatory data bytes.

ATR_REQ: 16 mandatory data bytes, giving a maximum of
48 General Bytes.
ATR_RES: 17 mandatory data bytes, giving a maximum of
47 General Bytes.

Regression introduced in commit a99903ec.

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
include/uapi/linux/nfc.h
net/nfc/nci/ntf.c

index 3c5efb1bc393a3ea0aa8480a746119671b195bc7..8119255feae4b44df8bac40415f4681a9ccf3c97 100644 (file)
@@ -205,6 +205,8 @@ enum nfc_sdp_attr {
 #define NFC_SENSF_RES_MAXSIZE          18
 #define NFC_ATR_REQ_MAXSIZE            64
 #define NFC_ATR_RES_MAXSIZE            64
+#define NFC_ATR_REQ_GB_MAXSIZE         48
+#define NFC_ATR_RES_GB_MAXSIZE         47
 #define NFC_GB_MAXSIZE                 48
 #define NFC_FIRMWARE_NAME_MAXSIZE      32
 #define NFC_ISO15693_UID_MAXSIZE       8
index 8dee73d0c4e1955c4214f66fa7de9b259740e2e3..22e453cb787d4d62e3246919f32ae5db14557ef3 100644 (file)
@@ -479,24 +479,22 @@ static int nci_store_general_bytes_nfc_dep(struct nci_dev *ndev,
        switch (ntf->activation_rf_tech_and_mode) {
        case NCI_NFC_A_PASSIVE_POLL_MODE:
        case NCI_NFC_F_PASSIVE_POLL_MODE:
-               /* ATR_RES general bytes at offset 15 */
                ndev->remote_gb_len = min_t(__u8,
                        (ntf->activation_params.poll_nfc_dep.atr_res_len
                                                - NFC_ATR_RES_GT_OFFSET),
-                       NFC_MAX_GT_LEN);
+                       NFC_ATR_RES_GB_MAXSIZE);
                memcpy(ndev->remote_gb,
-                      (ntf->activation_params.poll_nfc_dep .atr_res
+                      (ntf->activation_params.poll_nfc_dep.atr_res
                                                + NFC_ATR_RES_GT_OFFSET),
                       ndev->remote_gb_len);
                break;
 
        case NCI_NFC_A_PASSIVE_LISTEN_MODE:
        case NCI_NFC_F_PASSIVE_LISTEN_MODE:
-               /* ATR_REQ general bytes at offset 14 */
                ndev->remote_gb_len = min_t(__u8,
                        (ntf->activation_params.listen_nfc_dep.atr_req_len
                                                - NFC_ATR_REQ_GT_OFFSET),
-                       NFC_MAX_GT_LEN);
+                       NFC_ATR_REQ_GB_MAXSIZE);
                memcpy(ndev->remote_gb,
                       (ntf->activation_params.listen_nfc_dep.atr_req
                                                + NFC_ATR_REQ_GT_OFFSET),
This page took 0.056289 seconds and 5 git commands to generate.