]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
nfc: pn533: prevent potential memory corruption
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 2 Apr 2021 11:44:42 +0000 (14:44 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 2 Apr 2021 21:27:50 +0000 (14:27 -0700)
If the "type_a->nfcid_len" is too large then it would lead to memory
corruption in pn533_target_found_type_a() when we do:

memcpy(nfc_tgt->nfcid1, tgt_type_a->nfcid_data, nfc_tgt->nfcid1_len);

Fixes: c3b1e1e8a76f ("NFC: Export NFCID1 from pn533")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/nfc/pn533/pn533.c

index f1469ac8ff425346699a30e14d1dafddc63ce1c9..3fe5b81eda2d69a6856fae427bd3db803c373a41 100644 (file)
@@ -706,6 +706,9 @@ static bool pn533_target_type_a_is_valid(struct pn533_target_type_a *type_a,
        if (PN533_TYPE_A_SEL_CASCADE(type_a->sel_res) != 0)
                return false;
 
+       if (type_a->nfcid_len > NFC_NFCID1_MAXSIZE)
+               return false;
+
        return true;
 }