Upstream update e5e959835b195c023d1f685ef4dbbcfc3b5120b2

Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue Oct 25 17:11:11 2022 +0200

    fix buffer overflow when handling long composed input

    To reproduce the issue:

    "
    If you already have the multi-key enabled on your system, then add this line
    to your ~/.XCompose file:

    [...]
    <question> <T> <E> <S> <T> <question> :
    "1234567890123456789012345678901234567890123456789012345678901234567890"
    "

    Reported by and an initial patch by Andy Gozas <andy@gozas.me>, thanks!

    Adapted the patch, for now st (like dmenu) handles a fixed amount of composed
    characters, or otherwise ignores it. This is done for simplicity sake.
This commit is contained in:
Ashish Kumar Yadav 2022-11-08 10:49:30 +05:30
parent 916e612b6e
commit 8b8a6d23b4
1 changed files with 6 additions and 3 deletions

9
st/x.c
View File

@ -1868,7 +1868,7 @@ void
kpress(XEvent *ev)
{
XKeyEvent *e = &ev->xkey;
KeySym ksym;
KeySym ksym = NoSymbol;
char buf[64], *customkey;
int len;
Rune c;
@ -1878,10 +1878,13 @@ kpress(XEvent *ev)
if (IS_SET(MODE_KBDLOCK))
return;
if (xw.ime.xic)
if (xw.ime.xic) {
len = XmbLookupString(xw.ime.xic, e, buf, sizeof buf, &ksym, &status);
else
if (status == XBufferOverflow)
return;
} else {
len = XLookupString(e, buf, sizeof buf, &ksym, NULL);
}
/* 1. shortcuts */
for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
if (ksym == bp->keysym && match(bp->mod, e->state)) {