Such events can contain values that are incompatible with the core
keyboard map.
Fixes a potentially fatal error when such values are later used in a
XkbGetMap request.
Signed-off-by: Julian Orth <ju.orth@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/293>
Before this commit, using xkbcomp to compile a keymap that omits the key
type `ALPHABETIC` leads to either a wrong serialization (`-xkb` output)
or a server error such as:
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 135 (XKEYBOARD)
Minor opcode of failed request: 9 (XkbSetMap)
Value in failed request: 0x8010202
Serial number of failed request: 55
Current serial number in output stream: 60
Indeed, there is an error in the default key maps: the second field of
`XkbKTMapEntryRec` if a level index, not a modifier mask. While it worked
*by chance* for `ShiftMask` (e.g. the `TWO_LEVEL` type), it does not work
for `LockMask` (e.g. the `ALPHABETIC` type).
Fixed by using the correct level indices.
It probably went unnoticed for so long because xkbcomp and libxkbcommon
< 1.12 always use all the key types, while libxkbcommon ≥ 1.12 does not
serialize unused key types. The latter case may result in a keymap that
omits `ALPHABETIC`, e.g. with keyboard layouts with 4+ levels which use
alternative key types such as `FOUR_LEVEL_ALPHABETIC`.
Signed-off-by: Pierre Le Marre <dev@wismill.eu>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/292>
I can find nowhere in the source history where there was DEBUG code
that needed to include <stdio.h>, but the include of config.h should
never have been inside the DEBUG ifdef.
Resolves warnings from gcc 15 in 32-bit builds on Solaris of:
../../src/config.h:306:9: warning: "_FILE_OFFSET_BITS" redefined
Fixes: 7eee605e ("Conditionally include config.h in Xlib source")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/290>
Instead of calling malloc each time this function is invoked, use
the Quark database to ensure the return value lasts forever while not
leaking memory.
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Peter Harris <pharris2@rocketsoftware.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/282>
Clears 6571 complaints from `mandoc -T lint` of the form:
mandoc: man/xkb/XkbActionCtrls.3:107:4: STYLE: whitespace at end of input line
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/286>
When unsetting focus, the event filter is removed. This means a pending
fabricated event may not yet be sent to filter.
All the fabricated event state should be cleared and the pending sync
reply sent back as if the state is unfabricated.
Fix#235
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/283>
If XkbChangeTypesOfKey() is called with nGroups == 0, it will resize the
key syms to 0 but leave the key actions unchanged.
If later, the same function is called with a non-zero value for nGroups,
this will cause a buffer overflow because the key actions are of the wrong
size.
To avoid the issue, make sure to resize both the key syms and key actions
when nGroups is 0.
(cherry picked from xorg/xserver@0e4ed94952)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/279>
Resolves warning from Oracle Parfait static analyser:
Error: Uninitialised memory
Uninitialised memory variable [uninitialised-mem-var] (CWE 457):
Possible access to uninitialised memory referenced by variable 'mask'
at line 721 of xkb/XKBMisc.c in function 'XkbUpdateKeyTypeVirtualMods'.
Path in callee avoiding write at line 720
mask allocated at line 718
(cherry picked from xorg/xserver@a6574033f4)
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/279>
The current code seems to skip syms with width less than
type->num_levels when calculating the total size for the new
size_syms. This leads to less space being allocated than necessary
during the next phase, which is to copy over the syms to the new
location. This results in an overflow leading to a crash.
(cherry picked from xorg/xserver@42ae2e8199)
Signed-off-by: Siddhesh Poyarekar <siddhesh.poyarekar@gmail.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/279>
Because XkbFreeGeometry takes a pointer to the geometry structure,
and not the overall xkb structure like the other XkbFree*() calls,
the caller is responsible for clearing the xkb->geom pointer to
ensure it is not used after free.
Based on xorg/xserver@629798c73a
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/279>
There are two issues with the use of `UCSConvertCase` in `XConvertCase`:
- Some Latin-1 keysyms do not map within Latin-1, e.g. `ssharp`.
Only Latin-1 keysyms have the same value as the Unicode code point of
their corresponding character. So `UCSConvertCase` does not work for
some Latin-1 keysyms as it returns Unicode code points outside Latin-1
that do not match their corresponding keysyms values.
- Some Unicode keysyms should map to Latin-1 keysyms (<0x100). But the
Unicode keysym mask 0x01000000 is applied blindly to the result of
`UCSConvertCase`, resulting in invalid Unicode keysyms (0x010000nn)
while they should be Latin-1 keysyms.
Example with ß/ẞ:
```c
KeySym lower, upper;
XConvertCase(XK_ssharp, &lower, &upper);
// Expected: lower == XK_ssharp, upper == U1E9E
// Got: lower == XK_ssharp, upper == 0x1E9E
XConvertCase(U1E9E, &lower, &upper);
// Expected: lower == XK_ssharp, upper == U1E9E
// Got: lower == 0x10000df, upper == U1E9E
```
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/274>
Clears 8 warnings from clang of the form:
imDefIc.c:366:29: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
XIM_SET_PAD(&buf_s[2], len); /* pad */
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 10 warnings from clang of the form:
xcb_io.c:177:56: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
xcb_xlib_unknown_req_in_deq);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 24 warnings from clang of the form:
TextExt16.c:63:34: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
CI_GET_DEFAULT_INFO_1D (fs, def);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 5 warnings from clang of the form:
RdBitF.c:141:32: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
RETURN (BitmapFileInvalid);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 3 warnings from clang of the form:
PolyReg.c:224:67: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 4 warnings from clang of the form:
ParseCmd.c:158:43: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
PutCommandResource(options[i].value);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 4 warnings from clang of the form:
CrGlCur.c:140:64: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
GetFunc (TryShapeCursorFunc, "XcursorTryShapeCursor", func);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Makes them match the style of the other macros here and clears
up 5 clang warnings of the form:
Context.c:194:27: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
_XCreateMutex(&db->linfo);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 13 warnings from clang of the form:
Backgnd.c:44:72: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixel);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 6 warnings from clang of the form:
XKBBind.c:74:48: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
_XkbCheckPendingRefresh(dpy, dpy->xkb_info);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 4 warnings from clang of the form:
lcUtil.c:53:18: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
set_toupper(ch1);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 38 warnings from clang of the form:
cmsLkCol.c:155:35: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
Data (dpy, colorname, (long)n);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Clears 12 warnings from clang of the form:
cmsCmap.c:194:34: warning: empty expression statement has no effect;
remove unnecessary ';' to silence this warning [-Wextra-semi-stmt]
DeqAsyncHandler(dpy, &async);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/272>
Found by Oracle Parfait 13.3 static analyzer:
X Resource Leak [X-resource-leak]:
Leaked X Resource window
at line 306 of imDefIm.c in function '_XimPreConnectionIM'.
window initialized at line 300 with XCreateSimpleWindow
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/269>