From be614dbfa66e7d80f34926f12b52e7909c9f0e48 Mon Sep 17 00:00:00 2001 From: FeepingCreature Date: Sat, 20 Aug 2022 20:12:31 +0200 Subject: [PATCH] xkb: Avoid length-check failure on empty strings. _XkbCheckRequestBounds assumes that from..to is at least one byte. However, request strings can be empty, causing spurious failures in XkbGetKbdByName calls. To avoid this, before checking bounds make sure that the length is nonzero. (cherry picked from commit 79c572fbd349cb6373f685a502e430552f856995) --- xkb/xkb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xkb/xkb.c b/xkb/xkb.c index 0f5739b58..83c6250ad 100644 --- a/xkb/xkb.c +++ b/xkb/xkb.c @@ -5818,11 +5818,11 @@ GetComponentSpec(ClientPtr client, xkbGetKbdByNameReq *stuff, return NULL; } len = (*(unsigned char *) wire++); - if (!_XkbCheckRequestBounds(client, stuff, wire, wire + len)) { - *errRtrn = BadLength; - return NULL; - } if (len > 0) { + if (!_XkbCheckRequestBounds(client, stuff, wire, wire + len)) { + *errRtrn = BadLength; + return NULL; + } str = calloc(1, len + 1); if (str) { tmp = str;