[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v3 06/16] i2c: Add a length check to the SMBus write
From: |
minyard |
Subject: |
[Qemu-devel] [PATCH v3 06/16] i2c: Add a length check to the SMBus write handling |
Date: |
Mon, 26 Nov 2018 14:04:25 -0600 |
From: Corey Minyard <address@hidden>
Avoid an overflow.
Signed-off-by: Corey Minyard <address@hidden>
Reviewed-by: Peter Maydell <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 70ff29c095..d03f714608 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;
default:
--
2.17.1
- [Qemu-devel] [PATCH v3 01/16] i2c: Split smbus into parts, (continued)
- [Qemu-devel] [PATCH v3 01/16] i2c: Split smbus into parts, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 02/16] i2c: have I2C receive operation return uint8_t, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 11/16] i2c:smbus_slave: Add an SMBus vmstate structure, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 08/16] boards.h: Ignore migration for SMBus devices on older machines, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 07/16] i2c:pm_smbus: Fix pm_smbus handling of I2C block read, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 06/16] i2c: Add a length check to the SMBus write handling,
minyard <=
- [Qemu-devel] [PATCH v3 15/16] hw/i2c/smbus_eeprom: Create at most SMBUS_EEPROM_MAX EEPROMs on a SMBus, minyard, 2018/11/26
- [Qemu-devel] [PATCH v3 16/16] i2c:smbus_eeprom: Add a reset function to smbus_eeprom, minyard, 2018/11/26