mirror of https://gitee.com/openkylin/linux.git
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: 51bd6f2915
("Add support for IPMB driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Message-Id: <20200114144031.358003-1-colin.king@canonical.com>
Reviewed-by: Asmaa Mnebhi <asmaa@mellanox.com>
Signed-off-by: Corey Minyard <cminyard@mvista.com>
This commit is contained in:
parent
6b8526d3ab
commit
e0354d147e
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue