From 0732075869fa971a0c70b94bcc751a02963cfbe8 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 23 Nov 2020 19:31:52 +0800 Subject: [PATCH] graphics-server: bounds-check the circle drawing Otherwise we could overflow the buffer. Signed-off-by: Sean Cross --- services/graphics-server/src/op.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/graphics-server/src/op.rs b/services/graphics-server/src/op.rs index 497b38f0b..dea595578 100644 --- a/services/graphics-server/src/op.rs +++ b/services/graphics-server/src/op.rs @@ -280,6 +280,9 @@ fn line_fill_padded_border(fb: &mut LcdFB, y: usize) { } fn put_pixel(fb: &mut LcdFB, x: usize, y: usize, color: PixelColor) { + if (x >= LCD_PX_PER_LINE) || (y >= LCD_LINES) { + return; + } if color == PixelColor::Off { fb[(x + y * LCD_WORDS_PER_LINE * 32) / 32] |= 1 << (x % 32) } else {