|
|
fa07e0 |
From 18f91b950e22c2a342a4fbc55e9ddf7534a707d2 Mon Sep 17 00:00:00 2001
|
|
|
fa07e0 |
From: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
fa07e0 |
Date: Wed, 13 Jul 2022 11:23:09 +1000
|
|
|
fa07e0 |
Subject: [PATCH xserver] xkb: fix some possible memleaks in XkbGetKbdByName
|
|
|
fa07e0 |
|
|
|
fa07e0 |
GetComponentByName returns an allocated string, so let's free that if we
|
|
|
fa07e0 |
fail somewhere.
|
|
|
fa07e0 |
|
|
|
fa07e0 |
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
|
fa07e0 |
---
|
|
|
fa07e0 |
xkb/xkb.c | 26 ++++++++++++++++++++------
|
|
|
fa07e0 |
1 file changed, 20 insertions(+), 6 deletions(-)
|
|
|
fa07e0 |
|
|
|
fa07e0 |
diff --git a/xkb/xkb.c b/xkb/xkb.c
|
|
|
fa07e0 |
index 4692895db..b79a269e3 100644
|
|
|
fa07e0 |
--- a/xkb/xkb.c
|
|
|
fa07e0 |
+++ b/xkb/xkb.c
|
|
|
fa07e0 |
@@ -5935,18 +5935,32 @@ ProcXkbGetKbdByName(ClientPtr client)
|
|
|
fa07e0 |
xkb = dev->key->xkbInfo->desc;
|
|
|
fa07e0 |
status = Success;
|
|
|
fa07e0 |
str = (unsigned char *) &stuff[1];
|
|
|
fa07e0 |
- if (GetComponentSpec(&str, TRUE, &status)) /* keymap, unsupported */
|
|
|
fa07e0 |
- return BadMatch;
|
|
|
fa07e0 |
+ {
|
|
|
fa07e0 |
+ char *keymap = GetComponentSpec(&str, TRUE, &status); /* keymap, unsupported */
|
|
|
fa07e0 |
+ if (keymap) {
|
|
|
fa07e0 |
+ free(keymap);
|
|
|
fa07e0 |
+ return BadMatch;
|
|
|
fa07e0 |
+ }
|
|
|
fa07e0 |
+ }
|
|
|
fa07e0 |
names.keycodes = GetComponentSpec(&str, TRUE, &status);
|
|
|
fa07e0 |
names.types = GetComponentSpec(&str, TRUE, &status);
|
|
|
fa07e0 |
names.compat = GetComponentSpec(&str, TRUE, &status);
|
|
|
fa07e0 |
names.symbols = GetComponentSpec(&str, TRUE, &status);
|
|
|
fa07e0 |
names.geometry = GetComponentSpec(&str, TRUE, &status);
|
|
|
fa07e0 |
- if (status != Success)
|
|
|
fa07e0 |
+ if (status == Success) {
|
|
|
fa07e0 |
+ len = str - ((unsigned char *) stuff);
|
|
|
fa07e0 |
+ if ((XkbPaddedSize(len) / 4) != stuff->length)
|
|
|
fa07e0 |
+ status = BadLength;
|
|
|
fa07e0 |
+ }
|
|
|
fa07e0 |
+
|
|
|
fa07e0 |
+ if (status != Success) {
|
|
|
fa07e0 |
+ free(names.keycodes);
|
|
|
fa07e0 |
+ free(names.types);
|
|
|
fa07e0 |
+ free(names.compat);
|
|
|
fa07e0 |
+ free(names.symbols);
|
|
|
fa07e0 |
+ free(names.geometry);
|
|
|
fa07e0 |
return status;
|
|
|
fa07e0 |
- len = str - ((unsigned char *) stuff);
|
|
|
fa07e0 |
- if ((XkbPaddedSize(len) / 4) != stuff->length)
|
|
|
fa07e0 |
- return BadLength;
|
|
|
fa07e0 |
+ }
|
|
|
fa07e0 |
|
|
|
fa07e0 |
CHK_MASK_LEGAL(0x01, stuff->want, XkbGBN_AllComponentsMask);
|
|
|
fa07e0 |
CHK_MASK_LEGAL(0x02, stuff->need, XkbGBN_AllComponentsMask);
|
|
|
fa07e0 |
--
|
|
|
fa07e0 |
2.38.1
|
|
|
fa07e0 |
|