Skip to content

Commit

Permalink
drivers: ipmi: fix off-by-one bounds check that leads to a out-of-bou…
Browse files Browse the repository at this point in the history
…nds 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: 51bd6f2 ("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>
  • Loading branch information
Colin Ian King authored and Corey Minyard committed Jan 20, 2020
1 parent 6b8526d commit e0354d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/char/ipmi/ipmb_dev_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e0354d1

Please sign in to comment.