Commit a656bde1 authored by Christoph Berg's avatar Christoph Berg

Prevent segfault in commands.c when more than 8 keysyms per key are present.

parent 65e3bf8b
xkeycaps (2.47-5) unstable; urgency=medium
* Prevent segfault in commands.c when more than 8 keysyms per key are
present.
* Convert to format 3.0 (quilt).
* Modernize packaging using dh.
* Remove menu file.
......
The code only deals with 8 names per key, but unfortunately doesn't expose that
number as a constant that is easily changed. Clip to 8 so we don't segfault.
Program received signal SIGSEGV, Segmentation fault.
strlen () at ../sysdeps/x86_64/strlen.S:106
106 ../sysdeps/x86_64/strlen.S: Datei oder Verzeichnis nicht gefunden.
(gdb) bt
#0 strlen () at ../sysdeps/x86_64/strlen.S:106
#1 0x00007ffff6a2fa45 in __GI__IO_fputs (
str=str@entry=0x7fff0000000a <error: Cannot access memory at address 0x7fff0000000a>,
fp=fp@entry=0x5555559f6da0) at iofputs.c:33
#2 0x00005555555dc2a4 in fprintf (__fmt=0x5555555e49e1 "%s", __stream=<optimized out>)
at /usr/include/x86_64-linux-gnu/bits/stdio2.h:97
#3 button_write (button=<optimized out>, client_data=<optimized out>,
call_data=<optimized out>) at commands.c:629
#4 0x00007ffff7944aad in ?? () from /usr/lib/x86_64-linux-gnu/libXt.so.6
#5 0x00007ffff7944f15 in ?? () from /usr/lib/x86_64-linux-gnu/libXt.so.6
#6 0x00007ffff7945bdd in _XtTranslateEvent () from /usr/lib/x86_64-linux-gnu/libXt.so.6
#7 0x00007ffff791def2 in XtDispatchEventToWidget () from /usr/lib/x86_64-linux-gnu/libXt.so.6
#8 0x00007ffff791e8dd in ?? () from /usr/lib/x86_64-linux-gnu/libXt.so.6
#9 0x00007ffff791e9b9 in XtDispatchEvent () from /usr/lib/x86_64-linux-gnu/libXt.so.6
#10 0x00005555555d2d96 in xkeycaps_main_loop (app=0x5555559a81a0, keyboard=<optimized out>)
at xkeycaps.c:232
#11 main (argc=<optimized out>, argv=<optimized out>) at xkeycaps.c:355
(gdb) f 3
#3 button_write (button=<optimized out>, client_data=<optimized out>,
call_data=<optimized out>) at commands.c:629
629 fprintf (out, "%s", differences[i].names[j]);
(gdb) p i
$1 = 1
(gdb) p j
$2 = 9
(gdb) p differences
$3 = {{key = 0x555555a0dde0, count = 3, names = {0x7ffff6e13fc6 <_XkeyTable+134> "Escape",
0x5555555e4448 "NoSymbol", 0x7ffff6e13fc6 <_XkeyTable+134> "Escape", 0x0,
0x1d7 <error: Cannot access memory at address 0x1d7>,
0x1000 <error: Cannot access memory at address 0x1000>,
0x8 <error: Cannot access memory at address 0x8>,
0x5a42ab91 <error: Cannot access memory at address 0x5a42ab91>}}, {key = 0x555555a0dfa0,
count = 10, names = {0x7ffff6e144be <_XkeyTable+1406> "F1",
0x7ffff6e144be <_XkeyTable+1406> "F1", 0x7ffff6e144be <_XkeyTable+1406> "F1",
0x7ffff6e144be <_XkeyTable+1406> "F1", 0x7ffff6e144be <_XkeyTable+1406> "F1",
0x7ffff6e144be <_XkeyTable+1406> "F1",
0x7ffff6e1dfaf <_XkeyTable+41071> "XF86Switch_VT_1",
0x7ffff6e144be <_XkeyTable+1406> "F1"}}, {key = 0x555555a0e160, count = 10, names = {
0x7ffff6e144c7 <_XkeyTable+1415> "F2", 0x7ffff6e144c7 <_XkeyTable+1415> "F2",
0x7ffff6e144c7 <_XkeyTable+1415> "F2", 0x7ffff6e144c7 <_XkeyTable+1415> "F2",
0x7ffff6e144c7 <_XkeyTable+1415> "F2", 0x7ffff6e144c7 <_XkeyTable+1415> "F2",
0x7ffff6e1dfc5 <_XkeyTable+41093> "XF86Switch_VT_2",
0x7ffff6e144c7 <_XkeyTable+1415> "F2"}},
--- a/commands.c
+++ b/commands.c
@@ -440,6 +440,7 @@ button_write (button, client_data, call_
keysyms = XGetKeyboardMapping (XtDisplay (widget),
key->key.keycode,
1, &count);
+ if (count > 8) count = 8; /* FIXME: we are only prepared for 8 names per key, clip here */
if (! keysyms) count = 0;
all [all_count].key = key;
for (; count > 0; count--)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment