kbd/libkeymap-Fix-mk_mapname-for-the-plain-map.patch

53 lines
2.1 KiB
Diff
Raw Normal View History

From: Alexey Gladkov <gladkov.alexey@gmail.com>
Date: Sun, 23 Feb 2020 18:24:59 +0100
Subject: libkeymap: Fix mk_mapname for the plain map
Patch-mainline: 2.3
Git-commit: 88ae58fe8a223d11307accc36cc293133a18e7ac
mk_mapname did not correctly return "plain" for the plain map (no modifier set)
if it had already been called, as it did not correctly reset the static buffer
that it uses for the map name. When mk_mapname is called for the first time
from the first loop in lk_dump_ctable, all is fine, since buf has not been used
yet and it is initialised to 0. However, when it is called again for the plain
map from the second loop in lk_dump_ctable, buf already contains a value (left
over from the last iteration in the first loop), and then strcat appends
"plain" to that value instead of overwriting it, resulting in a bogus value.
Reported-by: Javier Pello <javier.pello@urjc.es>
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
src/libkeymap/dump.c | 2 +-
tests/data/dumpkeys-mktable/defkeymap.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libkeymap/dump.c b/src/libkeymap/dump.c
index 8531b5aa3d91..d67eefaada54 100644
--- a/src/libkeymap/dump.c
+++ b/src/libkeymap/dump.c
@@ -101,7 +101,7 @@ mk_mapname(char modifier)
int i;
if (!modifier) {
- strcat(buf, "plain");
+ strcpy(buf, "plain");
return buf;
}
buf[0] = 0;
diff --git a/tests/data/dumpkeys-mktable/defkeymap.c b/tests/data/dumpkeys-mktable/defkeymap.c
index e831316a1ff3..5d9a3aaeff8c 100644
--- a/tests/data/dumpkeys-mktable/defkeymap.c
+++ b/tests/data/dumpkeys-mktable/defkeymap.c
@@ -565,7 +565,7 @@ static unsigned short shift_altgr_ctrl_alt_map[NR_KEYS] = {
};
ushort *key_maps[MAX_NR_KEYMAPS] = {
- shift_altgr_ctrl_altplain_map, shift_map, altgr_map, shift_altgr_map,
+ plain_map, shift_map, altgr_map, shift_altgr_map,
ctrl_map, shift_ctrl_map, altgr_ctrl_map, shift_altgr_ctrl_map,
alt_map, shift_alt_map, altgr_alt_map, shift_altgr_alt_map,
ctrl_alt_map, shift_ctrl_alt_map, altgr_ctrl_alt_map, shift_altgr_ctrl_alt_map, 0
--
2.28.0