]> git.sur5r.net Git - i3/i3/commitdiff
error out instead of accepting invalid key bindings (Thanks SardemFF7)
authorMichael Stapelberg <michael@stapelberg.de>
Tue, 9 Oct 2012 12:05:37 +0000 (14:05 +0200)
committerMichael Stapelberg <michael@stapelberg.de>
Tue, 9 Oct 2012 12:09:08 +0000 (14:09 +0200)
src/config_directives.c

index c885b256949719c1d8645b7ca5b9e9ff94e4fa43..7847376dfa6b00952d0e02b26b77955d77f5ee32 100644 (file)
@@ -186,6 +186,10 @@ CFGFUN(binding, const char *bindtype, const char *modifiers, const char *key, co
     } else {
         // TODO: strtol with proper error handling
         new_binding->keycode = atoi(key);
+        if (new_binding->keycode == 0) {
+            ELOG("Could not parse \"%s\" as a keycode, ignoring this binding.\n", key);
+            return;
+        }
     }
     new_binding->mods = modifiers_from_str(modifiers);
     new_binding->command = sstrdup(command);
@@ -208,6 +212,10 @@ CFGFUN(mode_binding, const char *bindtype, const char *modifiers, const char *ke
     } else {
         // TODO: strtol with proper error handling
         new_binding->keycode = atoi(key);
+        if (new_binding->keycode == 0) {
+            ELOG("Could not parse \"%s\" as a keycode, ignoring this binding.\n", key);
+            return;
+        }
     }
     new_binding->mods = modifiers_from_str(modifiers);
     new_binding->command = sstrdup(command);