xserver/xkb
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Mikhail Dmitrichenko 1128987b8d xkb: use ssize_t for XKM byte counts
The ReadXkm* section readers return the number of bytes they consumed,
or -1 when they give up. That contract was spelled as int, while the
counters accumulating their results were a mix of int and unsigned, and
XkmGetCARD8/16/32() took the counter by reference as an int *.

XkmReadFile() also returns an unsigned, but that value is a bitmask of
the sections it could not read, not a byte count. Keeping byte counts in
unsigned variables right next to it makes the two easy to confuse, and
the confusion has a concrete cost: XkmReadFile() kept the readers'
results in an unsigned tmp, so the -1 that every one of the seven
readers it dispatches to can return became UINT_MAX. That passed the
tmp > 0 test below, and the section which had just failed to read was
marked as defined and cleared from the mask of sections reported as
missing.

Use ssize_t, the usual type for "a number of bytes, or -1 on failure",
for every byte count in this file: the section readers' return type, the
local counters, the counter XkmGetCARD8/16/32() take by reference, and
the return values of XkmSkipPadding() and XkmGetCountedString(). An
unsigned in this file now only ever denotes a bitmask, and a failing
section reader is no longer taken for a successful one.

ReadXkmKeyTypes() used a single tmp both for byte counts and as the
in/out element count handed to XkmInsureTypedSize(), which needs an
int *. That second use gets its own variable.

Signed-off-by: Mikhail Dmitrichenko <m.dmitrichenko222@gmail.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2304>
2026-10-08 20:51:56 +02:00
..
ddxBeep.c Handle -Wimplicit-fallthrough warnings from gcc 16.1 2026-08-24 12:41:10 +02:00
ddxCtrls.c xkb: unexport XkbDDX*() functions 2025-06-12 17:21:45 +02:00
ddxKillSrv.c
ddxLEDs.c xkb: unexport XkbDDX*() functions 2025-06-12 17:21:45 +02:00
ddxLoad.c xkb: zero out structs and arrays 2026-04-30 15:20:49 +02:00
ddxPrivate.c
ddxVT.c
maprules.c xkb: preserve buffer on realloc failure 2026-06-03 15:33:31 +02:00
meson.build xkb: inline remaining byte-swapping 2025-10-29 10:58:37 +01:00
README.compiled
xkb-procs.h xkb: inline remaining byte-swapping 2025-10-29 10:58:37 +01:00
xkb.c xkb: NULL text pointer after free in _CheckSetDoodad error path 2026-10-08 17:49:40 +02:00
xkbAccessX.c xkb: zero out structs and arrays 2026-04-30 15:20:49 +02:00
xkbActions.c xkb: Handle allocation failures in _XkbNextFreeFilter() 2026-05-01 18:43:16 +02:00
XKBAlloc.c xkb: allocate names->keys to MAP_LENGTH in XkbAllocNames 2026-10-08 17:48:48 +02:00
xkbDflts.h xkb: move include guards up to wrap the whole file 2025-11-21 15:20:11 +01:00
xkbEvents.c xkb: zero out structs and arrays 2026-04-30 15:20:49 +02:00
xkbfile_priv.h
xkbfmisc.c
xkbfmisc_priv.h
XKBGAlloc.c xkb: XkbAddGeomProperty(): handle OOM on strdup() 2026-04-30 18:43:18 +02:00
xkbgeom.h
xkbInit.c xkb: Default to one group whenever a keymap reports none 2026-10-05 09:23:49 +02:00
xkbLEDs.c xkb: zero out structs and arrays 2026-04-30 15:20:49 +02:00
XKBMAlloc.c xkb: widen size_syms, num_syms, size_acts, num_acts to unsigned int 2026-10-08 20:46:29 +02:00
XKBMisc.c xkb: zero out structs and arrays 2026-04-30 15:20:49 +02:00
xkbout.c
xkbout_priv.h
xkbPrKeyEv.c xkb: zero out structs and arrays 2026-04-30 15:20:49 +02:00
xkbrules_priv.h xkb: unexport XkbRF_VarDefsRec struct 2025-06-12 17:21:47 +02:00
xkbsrv_priv.h Revert "xkb: unexport XkbGetCoreMap() and XkbSetRepeatKeys()" 2026-06-16 06:48:41 +02:00
xkbtext.c xkb: zero out structs and arrays 2026-04-30 15:20:49 +02:00
xkbtext_priv.h
xkbUtils.c xkb: Guard XkbAdjustGroup() against a keymap with no groups 2026-10-05 09:23:49 +02:00
XKM_file_format.txt
xkmread.c xkb: use ssize_t for XKM byte counts 2026-10-08 20:51:56 +02:00

The X server uses this directory to store the compiled version of the
current keymap and/or any scratch keymaps used by clients.  The X server
or some other tool might destroy or replace the files in this directory,
so it is not a safe place to store compiled keymaps for long periods of
time.  The default keymap for any server is usually stored in:
     X<num>-default.xkm
where <num> is the display number of the server in question, which makes
it possible for several servers *on the same host* to share the same 
directory.

Unless the X server is modified, sharing this directory between servers on
different hosts could cause problems.