Skip to contentSkip to conversation

i2c-ddc: fix oob read

PATCH In review Gerd Hoffmann 3 participants 3 messages Jan 8, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c-ddc: fix oob read

---
 hw/i2c/i2c-ddc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i2c/i2c-ddc.c +1 -1
index be34fe072c..0a0367ff38 100644
@@ -56,7 +56,7 @@ static int i2c_ddc_rx(I2CSlave *i2c)
     I2CDDCState *s = I2CDDC(i2c);
 
     int value;
-    value = s->edid_blob[s->reg];
+    value = s->edid_blob[s->reg % sizeof(s->edid_blob)];
     s->reg++;
     return value;
 }
Signature · 1 line
2.9.3
Reviewed-by on v1 1/1
#2 lore raw
In reply to Gerd Hoffmann
Quoted 12 lines · Gerd Hoffmann
---
 hw/i2c/i2c-ddc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i2c/i2c-ddc.c +0 -0
index be34fe072c..0a0367ff38 100644

hw/i2c/i2c-ddc.c static int i2c_ddc_rx(I2CSlave *i2c) · line 62

Quoted 8 lines
hw/i2c/i2c-ddc.c +1 -1
@@ -56,7 +56,7 @@ static int i2c_ddc_rx(I2CSlave *i2c)
     I2CDDCState *s = I2CDDC(i2c);
 
     int value;
-    value = s->edid_blob[s->reg];
+    value = s->edid_blob[s->reg % sizeof(s->edid_blob)];
     s->reg++;
     return value;
 }