From 395fb7ac0dd57f9352a4001b4456095c47a63ef3 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 23 Jun 2025 13:31:17 -0400 Subject: usr.bin: kfgwm: Ensure x/y does not overflow Signed-off-by: Ian Moffett --- usr.bin/kfgwm/window.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/usr.bin/kfgwm/window.c b/usr.bin/kfgwm/window.c index 0bc961b..8954553 100644 --- a/usr.bin/kfgwm/window.c +++ b/usr.bin/kfgwm/window.c @@ -77,6 +77,11 @@ draw_win(struct kfg_window *parent, struct kfg_window *wp) x_end = x_i + wp->width; y_end = y_i + wp->height; + if (x_end > parent->width) + x_end = parent->width; + if (y_end > parent->height) + y_end = parent->height; + for (kfgpos_t x = x_i; x < x_end; ++x) { for (kfgpos_t y = y_i; y < y_i+KFG_TITLE_HEIGHT; ++y) { rx = (x - x_i); -- cgit v1.2.3