Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb450f79 authored by Suren Baghdasaryan's avatar Suren Baghdasaryan Committed by Amit Pundir
Browse files

ANDROID: nfc: fdp: Fix possible buffer overflow in WCS4000 NFC driver



Possible buffer overflow when reading next_read_size bytes into
tmp buffer after next_read_size was extracted from a previous packet.

Bug: 62678828

Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
parent 7f54bf16
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -176,6 +176,16 @@ static int fdp_nci_i2c_read(struct fdp_i2c_phy *phy, struct sk_buff **skb)
		/* Packet that contains a length */
		/* Packet that contains a length */
		if (tmp[0] == 0 && tmp[1] == 0) {
		if (tmp[0] == 0 && tmp[1] == 0) {
			phy->next_read_size = (tmp[2] << 8) + tmp[3] + 3;
			phy->next_read_size = (tmp[2] << 8) + tmp[3] + 3;
			/*
			 * Ensure next_read_size does not exceed sizeof(tmp)
			 * for reading that many bytes during next iteration
			 */
			if (phy->next_read_size > FDP_NCI_I2C_MAX_PAYLOAD) {
				dev_dbg(&client->dev, "%s: corrupted packet\n",
					__func__);
				phy->next_read_size = 5;
				goto flush;
			}
		} else {
		} else {
			phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;
			phy->next_read_size = FDP_NCI_I2C_MIN_PAYLOAD;