aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-03-04 16:54:19 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-03-04 16:54:19 +0000
commit6e536e7ed8f1de2615fa323123ddb2b06a45a179 (patch)
treecab1826063b3597cad234d6077e11fb208332861
parentdcs: prevent possibility of out-of-bounds reads in decrqss() (diff)
input: get_current_modifiers(): don’t crash if seat has no keyboard
Closes #963
-rw-r--r--CHANGELOG.md4
-rw-r--r--input.c21
2 files changed, 19 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48e5b6d0..8f523d5f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -46,6 +46,7 @@
* `[key-bindings].scrollback-home|end` options.
* Socket activation for `foot --server` and accompanying systemd unit files
+
### Changed
* Minimum required meson version is now 0.58.
@@ -62,6 +63,7 @@
The kitty keyboard protocol (added in release 1.10.3) can
be used to similar effect.
+
### Fixed
* Build: missing `wayland_client` dependency in `test-config`
@@ -79,6 +81,8 @@
(https://codeberg.org/dnkl/foot/issues/943).
* Key binding collisions not detected for bindings specified as option
overrides on the command line.
+* Crash when seat has no keyboard
+ (https://codeberg.org/dnkl/foot/issues/963).
### Security
diff --git a/input.c b/input.c
index f402fa3d..047d7c86 100644
--- a/input.c
+++ b/input.c
@@ -1010,14 +1010,23 @@ get_current_modifiers(const struct seat *seat,
xkb_mod_mask_t *effective,
xkb_mod_mask_t *consumed, uint32_t key)
{
- if (effective != NULL) {
- *effective = xkb_state_serialize_mods(
- seat->kbd.xkb_state, XKB_STATE_MODS_EFFECTIVE);
+ if (unlikely(seat->kbd.xkb_state == NULL)) {
+ if (effective != NULL)
+ *effective = 0;
+ if (consumed != NULL)
+ *consumed = 0;
}
- if (consumed != NULL) {
- *consumed = xkb_state_key_get_consumed_mods2(
- seat->kbd.xkb_state, key, XKB_CONSUMED_MODE_XKB);
+ else {
+ if (effective != NULL) {
+ *effective = xkb_state_serialize_mods(
+ seat->kbd.xkb_state, XKB_STATE_MODS_EFFECTIVE);
+ }
+
+ if (consumed != NULL) {
+ *consumed = xkb_state_key_get_consumed_mods2(
+ seat->kbd.xkb_state, key, XKB_CONSUMED_MODE_XKB);
+ }
}
}