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

drivers: ipmi: fix off-by-one bounds check that leads to a out-of-bounds write



The end of buffer check is off-by-one since the check is against
an index that is pre-incremented before a store to buf[]. Fix this
adjusting the bounds check appropriately.

Addresses-Coverity: ("Out-of-bounds write")
Fixes: 51bd6f29 ("Add support for IPMB driver")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Message-Id: <20200114144031.358003-1-colin.king@canonical.com>
Reviewed-by: default avatarAsmaa Mnebhi <asmaa@mellanox.com>
Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
parent 6b8526d3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ static int ipmb_slave_cb(struct i2c_client *client,
		break;

	case I2C_SLAVE_WRITE_RECEIVED:
		if (ipmb_dev->msg_idx >= sizeof(struct ipmb_msg))
		if (ipmb_dev->msg_idx >= sizeof(struct ipmb_msg) - 1)
			break;

		buf[++ipmb_dev->msg_idx] = *val;