From e0380c6b0a507cbd585ab6d9aa9e640c09a0879e Mon Sep 17 00:00:00 2001 From: Erin Date: Mon, 18 Sep 2017 22:30:01 -0500 Subject: [PATCH] vga_console: bounds-check move_cursor() --- src/arch/x86_64/device/vga_console.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/arch/x86_64/device/vga_console.rs b/src/arch/x86_64/device/vga_console.rs index 70ab159..106078b 100644 --- a/src/arch/x86_64/device/vga_console.rs +++ b/src/arch/x86_64/device/vga_console.rs @@ -121,6 +121,9 @@ impl Writer { /// Move the _console cursor_ (blinky bar) to (row, col). fn move_cursor(&mut self, row: usize, col: usize) { + assert!(row < BUFFER_HEIGHT, "attempted out-of-bounds (row) cursor move"); + assert!(col < BUFFER_WIDTH, "attempted out-of-bounds (col) cursor move"); + let pos: u16 = ((row * 80) + col) as u16; // Lovingly ripped off from wiki.osdev.org/Text_Mode_Cursor unsafe {