Skip to contentSkip to conversation

hw/display/framebuffer.c: Avoid overflow for framebuffers > 4GB

PATCH Applied Peter Maydell 2 participants 2 messages Jan 9, 2017 – Jan 12, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/display/framebuffer.c: Avoid overflow for framebuffers > 4GB

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)

---
 hw/display/framebuffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/framebuffer.c +1 -1
index df51358..25aa46c 100644
@@ -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) {
Signature · 1 line
2.7.4
#1 lore raw
Quoted 4 lines · Peter Maydell

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)

Applied to -trivial, thanks!

/mjt