NFC: port100: Fix possible buffer overflow
authorThierry Escande <thierry.escande@linux.intel.com>
Sun, 26 Jan 2014 23:31:14 +0000 (00:31 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 16 Feb 2014 22:49:54 +0000 (23:49 +0100)
The arrays for protocols and rf techs must define a number of entries
corresponding to their maximum possible index values.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/port100.c

index a8555f81cbbac2ce4dac42c509d898228cc451f3..24f5e023f2a5ca520bb9d5e806bfec1c1c84d6de 100644 (file)
@@ -139,6 +139,8 @@ static const struct port100_in_rf_setting in_rf_settings[] = {
                .in_recv_set_number = 15,
                .in_recv_comm_type  = PORT100_COMM_TYPE_IN_106A,
        },
+       /* Ensures the array has NFC_DIGITAL_RF_TECH_LAST elements */
+       [NFC_DIGITAL_RF_TECH_LAST] = { 0 },
 };
 
 /**
@@ -174,6 +176,9 @@ static const struct port100_tg_rf_setting tg_rf_settings[] = {
                .tg_set_number = 8,
                .tg_comm_type = PORT100_COMM_TYPE_TG_424F,
        },
+       /* Ensures the array has NFC_DIGITAL_RF_TECH_LAST elements */
+       [NFC_DIGITAL_RF_TECH_LAST] = { 0 },
+
 };
 
 #define PORT100_IN_PROT_INITIAL_GUARD_TIME      0x00
@@ -330,6 +335,10 @@ in_protocols[][PORT100_IN_MAX_NUM_PROTOCOLS + 1] = {
        [NFC_DIGITAL_FRAMING_NFC_DEP_ACTIVATED] = {
                { PORT100_IN_PROT_END, 0 },
        },
+       /* Ensures the array has NFC_DIGITAL_FRAMING_LAST elements */
+       [NFC_DIGITAL_FRAMING_LAST] = {
+               { PORT100_IN_PROT_END, 0 },
+       },
 };
 
 static struct port100_protocol
@@ -371,6 +380,10 @@ tg_protocols[][PORT100_TG_MAX_NUM_PROTOCOLS + 1] = {
                { PORT100_TG_PROT_RF_OFF, 1 },
                { PORT100_TG_PROT_END,    0 },
        },
+       /* Ensures the array has NFC_DIGITAL_FRAMING_LAST elements */
+       [NFC_DIGITAL_FRAMING_LAST] = {
+               { PORT100_TG_PROT_END,    0 },
+       },
 };
 
 struct port100 {