[PULL,25/31] hw/display/framebuffer.c: Avoid overflow for framebuffers > 4GB

Message ID 05a23aeae1dc56b7f26c1a348fd6d31790f6baa6.1485250702.git.mjt@msgid.tls.msk.ru
State New
Headers show
Series
  • Untitled series #159
Related show

Commit Message

Michael Tokarev Jan. 24, 2017, 9:39 a.m.
From: Peter Maydell <peter.maydell@linaro.org>


Coverity points out that calculating src_len by multiplying
src_width by rows could overflow. This can only happen in
the implausible case of a framebuffer larger than 4GB, but
we may as well fix it, placating Coverity. (CID1005515)

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>

---
 hw/display/framebuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.1.4

Patch hide | download patch | download mbox

diff --git a/hw/display/framebuffer.c b/hw/display/framebuffer.c
index df51358..25aa46c 100644
--- a/hw/display/framebuffer.c
+++ b/hw/display/framebuffer.c
@@ -78,7 +78,7 @@  void framebuffer_update_display(
 
     i = *first_row;
     *first_row = -1;
-    src_len = src_width * rows;
+    src_len = (hwaddr)src_width * rows;
 
     mem = mem_section->mr;
     if (!mem) {