Commit 39ce7350 authored by Colin Ian King's avatar Colin Ian King Committed by Corey Minyard
Browse files

ipmi: ipmb: Fix off-by-one size check on rcvlen



There is an off-by-one bounds check on the rcvlen causing a potential
out of bounds write on iidev->rcvmsg. Fix this by using the >= operator
on the bounds check rather than the > operator.

Addresses-Coverity: ("Out-of-bounds write")
Fixes: 0ba0c3c5d1c1 ("ipmi:ipmb: Add initial support for IPMI over IPMB")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Message-Id: <20211005151611.305383-1-colin.king@canonical.com>
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
parent 8332cd49
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ static int ipmi_ipmb_slave_cb(struct i2c_client *client,
		break;

	case I2C_SLAVE_WRITE_RECEIVED:
		if (iidev->rcvlen > sizeof(iidev->rcvmsg))
		if (iidev->rcvlen >= sizeof(iidev->rcvmsg))
			iidev->overrun = true;
		else
			iidev->rcvmsg[iidev->rcvlen++] = *val;