mifare: Fix possible NULL pointer dereference in reading loop
authorDorota Moskal <dorota.moskal@tieto.com>
Thu, 27 Sep 2012 11:22:12 +0000 (13:22 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 9 Oct 2012 18:27:11 +0000 (20:27 +0200)
After reading first sector, reading loop should check if sector list
is NULL in case only one valid NFC sector is present.

plugins/mifare.c

index 0af07da..03e5921 100644 (file)
@@ -418,7 +418,7 @@ static int mifare_read_NFC_loop(uint8_t *resp, int length, void *data)
 
 
        /* Additional sectors to read ? */;
-       if (mf_ck->g_sect_list->next != NULL) {
+       if (mf_ck->g_sect_list != NULL && mf_ck->g_sect_list->next != NULL) {
 
                err = mifare_read_sector(data,  /* cookie */
                        mf_ck->nfc_data,                /* where to store */