From 5ebf0a9dd72eaeca4713685f024ec7cab0a66961 Mon Sep 17 00:00:00 2001 From: Pierre Le Marre Date: Thu, 16 Oct 2025 07:06:38 +0200 Subject: [PATCH] xkb: Fix serialization of key type without level names Before this commit the count of key type level names was wrongly set in `XkbGetNames`: for key type without names, it was set to the level count, while it should be 0: - `XkbComputeGetNamesReplySize()` does not account key type without level names; - `XkbSendNames()` does not write any level entry for key types without level names. This causes a mismatch offset while parsing the response and its processing would ultimately fail. Fixed by setting the correct level name count: 0 if there is no level name, else the number of levels. (cherry picked from commit c49cbc176a65892fb1109fee5c6e8316a771f5e6) Part-of: --- xkb/xkb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index 137d70da2..f3cc05c4e 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -3949,7 +3949,8 @@ XkbSendNames(ClientPtr client, XkbDescPtr xkb, xkbGetNamesReply * rep) register CARD32 *atm; for (i = 0; i < rep->nTypes; i++, type++) { - *desc++ = type->num_levels; + /* Either no name or all of them, even empty ones */ + *desc++ = (type->level_names) ? type->num_levels : 0; } desc += XkbPaddedSize(rep->nTypes) - rep->nTypes;