diff mbox series

i2c-ddc: fix oob read

Message ID 20190108102301.1957-1-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series i2c-ddc: fix oob read | expand

Commit Message

Gerd Hoffmann Jan. 8, 2019, 10:23 a.m. UTC
Suggested-by: Michael Hanselmann <public@hansmi.ch>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/i2c/i2c-ddc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Hanselmann Jan. 8, 2019, 10:38 a.m. UTC | #1
On 08.01.19 11:23, Gerd Hoffmann wrote:
> Suggested-by: Michael Hanselmann <public@hansmi.ch>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Looks good to me.

Reviewed-by: Michael Hanselmann <public@hansmi.ch>
Philippe Mathieu-Daudé Jan. 8, 2019, 2:31 p.m. UTC | #2
On 1/8/19 11:23 AM, Gerd Hoffmann wrote:
> Suggested-by: Michael Hanselmann <public@hansmi.ch>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  hw/i2c/i2c-ddc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/i2c/i2c-ddc.c b/hw/i2c/i2c-ddc.c
> index be34fe072c..0a0367ff38 100644
> --- a/hw/i2c/i2c-ddc.c
> +++ b/hw/i2c/i2c-ddc.c
> @@ -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;
>  }
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
diff mbox series

Patch

diff --git a/hw/i2c/i2c-ddc.c b/hw/i2c/i2c-ddc.c
index be34fe072c..0a0367ff38 100644
--- a/hw/i2c/i2c-ddc.c
+++ b/hw/i2c/i2c-ddc.c
@@ -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;
 }