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>
Avoids build failures with gcc 14.2 when MALLOC_0_RETURNS_NULL is defined:
imCallbk.c:346:9: error: ‘memcpy’ offset 10 is out of the bounds [0, 1]
[-Werror=array-bounds=]
346 | memcpy(&buf[p],&cbrec.text->string.mbs,length_in_bytes);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/267>
Avoids build failures with gcc 14.2 when MALLOC_0_RETURNS_NULL is defined:
imDefIm.c: In function ‘_XimEncodingNegotiation’:
imDefIm.c:1739:15: error: ‘memcpy’ offset 8 is out of the bounds [0, 1]
[-Werror=array-bounds=]
1739 | (void)memcpy((char *)&buf_s[2], name_ptr, name_len);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/267>
Clears warning from gcc 14.1:
SetFPath.c: In function ‘XSetFontPath’:
../include/X11/Xlibint.h:463:24: warning: argument 1 value is zero
[-Walloc-zero]
463 | # define Xmalloc(size) malloc((size_t)(size))
| ^~~~~~~~~~~~~~~~~~~~~~
SetFPath.c:61:18: note: in expansion of macro ‘Xmalloc’
61 | if ((p = Xmalloc (nbytes))) {
| ^~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/266>
Commit 1472048b7 to fix a colormap threading issue added a display
lock/unlock and a call to SyncHandle() to _XcmsFreeClientCmaps().
When running synchronized, that means calling XSync().
_XcmsFreeClientCmaps() is called from _XFreeDisplayStructure() via
XCloseDisplay() after the xcb connection is closed.
So when running synchronized, we may end up calling XSync() after the
xcb connection to the display is closed, which will generate a spurious
XIO error:
| #0 in _XDefaultIOError () at /lib64/libX11.so.6
| #1 in _XIOError () at /lib64/libX11.so.6
| #2 in _XReply () at /lib64/libX11.so.6
| #3 in XSync () at /lib64/libX11.so.6
| #4 in _XSyncFunction () at /lib64/libX11.so.6
| 8#5 in _XFreeDisplayStructure () at /lib64/libX11.so.6
| 8#6 in XCloseDisplay () at /lib64/libX11.so.6
To avoid that issue, closed the xcb connection to the display last.
v2: And same in OutOfMemory() as well (José Expósito)
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: José Expósito <jexposit@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libx11/-/merge_requests/264>