hw/display/artist: Check offset in draw_line to avoid buffer over-run
commitb87a7355de04a2771c11824ea791802c052c979c
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Sat, 23 May 2020 19:15:15 +0000 (23 21:15 +0200)
committerHelge Deller <deller@gmx.de>
Wed, 26 Aug 2020 21:04:00 +0000 (26 23:04 +0200)
tree7e69cd2959bc8a3f3f84f621f3e52eea278803b3
parentb899fe41ceb9c684fa135a081f4c9749400a61d3
hw/display/artist: Check offset in draw_line to avoid buffer over-run

Invalid I/O writes can craft an offset out of the vram_buffer range.

We avoid:

  Program terminated with signal SIGSEGV, Segmentation fault.
  284             *dst &= ~plane_mask;
  (gdb) bt
  #0  0x000055d5dccdc5c0 in artist_rop8 (s=0x55d5defee510, dst=0x7f8e84ed8216 <error: Cannot access memory at address 0x7f8e84ed8216>, val=0 '\000') at hw/display/artist.c:284
  #1  0x000055d5dccdcf83 in fill_window (s=0x55d5defee510, startx=22, starty=5674, width=65, height=5697) at hw/display/artist.c:551
  #2  0x000055d5dccddfb9 in artist_reg_write (opaque=0x55d5defee510, addr=1051140, val=4265537, size=4) at hw/display/artist.c:902
  #3  0x000055d5dcb42a7c in memory_region_write_accessor (mr=0x55d5defeea10, addr=1051140, value=0x7ffe57db08c8, size=4, shift=0, mask=4294967295, attrs=...) at memory.c:483

Reported-by: LLVM libFuzzer
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Helge Deller <deller@gmx.de>
hw/display/artist.c