]> git.mdlowis.com Git - proto/labwc.git/commitdiff
config/keybind.c: Don't overwrite the stack
authorConsolatis <35009135+Consolatis@users.noreply.github.com>
Mon, 3 Jan 2022 04:38:48 +0000 (05:38 +0100)
committerJohan Malm <johanmalm@users.noreply.github.com>
Mon, 3 Jan 2022 08:27:22 +0000 (08:27 +0000)
include/config/keybind.h
src/config/keybind.c

index fcb4bc83d6656d5eb42313f5ff3f0f0d29695a56..78caf9a311ccfc502e7f807bad824c053acebcb1 100644 (file)
@@ -5,6 +5,8 @@
 #include <wlr/types/wlr_keyboard.h>
 #include <xkbcommon/xkbcommon.h>
 
+#define MAX_KEYSYMS 32
+
 struct keybind {
        uint32_t modifiers;
        xkb_keysym_t *keysyms;
index 3ef925dae1675fdbb163a8c77bca06b70ef3e4fd..3a6066ee6cf81412260937a4e8442c407656baa7 100644 (file)
@@ -28,7 +28,7 @@ struct keybind *
 keybind_create(const char *keybind)
 {
        struct keybind *k = calloc(1, sizeof(struct keybind));
-       xkb_keysym_t keysyms[32];
+       xkb_keysym_t keysyms[MAX_KEYSYMS];
        gchar **symnames = g_strsplit(keybind, "-", -1);
        for (int i = 0; symnames[i]; i++) {
                char *symname = symnames[i];
@@ -46,6 +46,12 @@ keybind_create(const char *keybind)
                        }
                        keysyms[k->keysyms_len] = sym;
                        k->keysyms_len++;
+                       if (k->keysyms_len == MAX_KEYSYMS) {
+                               wlr_log(WLR_ERROR, "There are a lot of fingers involved. "
+                                       "We stopped counting at %u.", MAX_KEYSYMS);
+                               wlr_log(WLR_ERROR, "Offending keybind was %s", keybind);
+                               break;
+                       }
                }
        }
        g_strfreev(symnames);