From ee71d0bde97c2caa0d9c3c14a370d73f8e0ef627 Mon Sep 17 00:00:00 2001 From: project-repo Date: Sat, 24 Dec 2022 08:03:06 +0100 Subject: [PATCH] Add check to prevent buffer overflow --- keybinding.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/keybinding.c b/keybinding.c index 6ebbc5a..9a3f908 100644 --- a/keybinding.c +++ b/keybinding.c @@ -807,6 +807,10 @@ print_modes(struct dyn_str *str, char **modes) { ++nmemb; ++tmp; } + if(nmemb==0) { + wlr_log(WLR_ERROR,"This is a bug: Cagebreak has no valid modes. This should not occur, since default modes are defined on startup."); + return; + } /* We are assuming here that we have at least one mode, which is given by * the initialization of cagebreak */ char *modes_str = calloc(len + 3 * (nmemb - 1) + 1, sizeof(char));