[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 04/12] i2c: Add a length check to the SMBus w
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH v2 04/12] i2c: Add a length check to the SMBus write handling |
Date: |
Tue, 20 Nov 2018 15:33:19 +0000 |
On 15 November 2018 at 19:24, <address@hidden> wrote:
> From: Corey Minyard <address@hidden>
>
> Avoid an overflow.
>
> Signed-off-by: Corey Minyard <address@hidden>
> ---
> hw/i2c/smbus_slave.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i2c/smbus_slave.c b/hw/i2c/smbus_slave.c
> index 83ca041b5d..fa988919d8 100644
> --- a/hw/i2c/smbus_slave.c
> +++ b/hw/i2c/smbus_slave.c
> @@ -182,7 +182,11 @@ static int smbus_i2c_send(I2CSlave *s, uint8_t data)
> switch (dev->mode) {
> case SMBUS_WRITE_DATA:
> DPRINTF("Write data %02x\n", data);
> - dev->data_buf[dev->data_len++] = data;
> + if (dev->data_len >= sizeof(dev->data_buf)) {
> + BADF("Too many bytes sent\n");
> + } else {
> + dev->data_buf[dev->data_len++] = data;
> + }
> break;
Reviewed-by: Peter Maydell <address@hidden>
What happens on a real device in this situation ?
thanks
-- PMM
- [Qemu-devel] [PATCH v2 00/12] RFC: Fix/add vmstate handling in some I2C code, minyard, 2018/11/15
- [Qemu-devel] [PATCH v2 03/12] i2c: Simplify and correct the SMBus state machine, minyard, 2018/11/15
- [Qemu-devel] [PATCH v2 04/12] i2c: Add a length check to the SMBus write handling, minyard, 2018/11/15
- Re: [Qemu-devel] [PATCH v2 04/12] i2c: Add a length check to the SMBus write handling,
Peter Maydell <=
- [Qemu-devel] [PATCH v2 01/12] i2c: Split smbus into parts, minyard, 2018/11/15
- [Qemu-devel] [PATCH v2 02/12] i2c: have I2C receive operation return uint8_t, minyard, 2018/11/15
- [Qemu-devel] [PATCH v2 05/12] i2c: Fix pm_smbus handling of I2C block read, minyard, 2018/11/15