diff options
author | Anton Kling <anton@kling.gg> | 2024-07-01 15:50:23 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-07-01 15:50:23 +0200 |
commit | ab09d1f56f5881eb5d2234038d9146f74deecc10 (patch) | |
tree | c2e3a30c7366d3d8f6dc99f9e0dd6f22269256fc /userland | |
parent | 8f899881c678bb6b22bf4d1594648da545379755 (diff) |
Terminal: Avoid out of bounds access on resize
Diffstat (limited to 'userland')
-rw-r--r-- | userland/terminal/term.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/userland/terminal/term.c b/userland/terminal/term.c index bff6eab..abb150c 100644 --- a/userland/terminal/term.c +++ b/userland/terminal/term.c @@ -5,16 +5,16 @@ #include <poll.h> #include <pty.h> #include <signal.h> -#include <sys/socket.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> +#include <sys/socket.h> #include <unistd.h> #define TERM_BACKGROUND 0x000000 -char terminal_char_buffer[1920 / 8][1080 / 8] = {0}; +char terminal_char_buffer[1080 / 8][1920 / 8] = {0}; int cmdfd; GUI_Window *global_w; @@ -230,8 +230,14 @@ void handle_escape_codes_or_print(char *buffer, int len) { void terminal_resize(uint32_t sx, uint32_t sy) { assert(GUI_BufferResize(global_w, sx, sy)); for (int y = 0; y < sy; y += 8) { + if (y / 8 >= 1080 / 8) { + break; + } int x = 0; for (; x < sx; x += 8) { + if (x / 8 >= 1920 / 8) { + break; + } GUI_DrawFont(global_w, x, y, terminal_char_buffer[y / 8][x / 8]); } } |