Skip to contentSkip to conversation

NFC: potential integer overflow problem in check_crc()

PATCH New Dan Carpenter 1 participant 1 message May 18, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFC: potential integer overflow problem in check_crc()

If "buf[0]" is 255 then "len" gets set to 0. The call to "crc_ccitt(0xffff, buf, len - 2);" casts the "len - 2" to a high positive number which is ugly.

drivers/nfc/pn544_hci.c +1 -1
index 46f4a9f..281f18c 100644
@@ -232,7 +232,7 @@ static int pn544_hci_i2c_write(struct i2c_client *client, u8 *buf, int len)
 
 static int check_crc(u8 *buf, int buflen)
 {
-	u8 len;
+	int len;
 	u16 crc;
 
 	len = buf[0] + 1;