projf-explore icon indicating copy to clipboard operation
projf-explore copied to clipboard

Verilator/SDL Screen Array Unchecked (C++)

Open WillGreen opened this issue 4 years ago • 0 comments

We don't check the SDL/Verilator screenbuffer array index is valid.

Pixel screenbuffer[H_RES*V_RES];

// update pixel if not in blanking interval
if (top->sdl_de) {
      Pixel* p = &screenbuffer[top->sdl_sy*H_RES + top->sdl_sx];
      p->a = 0xFF;  // transparency
      p->b = top->sdl_b;
      p->g = top->sdl_g;
      p->r = top->sdl_r;
  }

An invalid index will corrupt the simulation or (more likely) cause a core dump.

The display signals module should never set sdl_de high with an invalid sdl_sy or sdl_sx, but we shouldn't assume this.

WillGreen avatar Feb 07 '22 12:02 WillGreen