xserver: Branch 'master' - 2 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Feb 25 17:18:51 UTC 2020
xkb/xkb.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
New commits:
commit de940e06f8733d87bbb857aef85d830053442cfe
Author: Peter Harris <pharris at opentext.com>
Date: Thu Nov 14 14:06:21 2019 -0500
xkb: fix key type index check in _XkbSetMapChecks
This code block was moved from a function that returns 0 for failure to a
function that returns 0 for Success in commit
649293f6b634e6305b6737a841d6e9d0f0065d6c. Change the return value to
BadValue to match the other checks in _XkbSetMapChecks.
Set nTypes to xkb->map->num_types when XkbKeyTypesMask is not set, to
allow requests with the XkbKeyTypesMask flag unset in stuff->present to
succeed.
Fixes a potential heap smash when client->swapped is true, because the
remainder of the request will not be swapped after "return 0", but
_XkbSetMap will be called anyway (because 0 is Success).
Signed-off-by: Peter Harris <pharris at opentext.com>
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 9ffaf68fb..d93078a6e 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -2419,6 +2419,9 @@ _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req,
client->errorValue = nTypes;
return BadValue;
}
+ else {
+ nTypes = xkb->map->num_types;
+ }
/* symsPerKey/mapWidths must be filled regardless of client-side flags */
map = &xkb->map->key_sym_map[xkb->min_key_code];
@@ -2429,7 +2432,7 @@ _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req,
for (w = g = 0; g < ng; g++) {
if (map->kt_index[g] >= (unsigned) nTypes) {
client->errorValue = _XkbErrCode4(0x13, i, g, map->kt_index[g]);
- return 0;
+ return BadValue;
}
if (mapWidths[map->kt_index[g]] > w)
w = mapWidths[map->kt_index[g]];
commit 270e439739e023463e7e0719a4eede69d45f7a3f
Author: Peter Harris <pharris at opentext.com>
Date: Thu Nov 14 14:00:31 2019 -0500
xkb: only swap once in XkbSetMap
The server swaps part of the request in _XkbSetMapChecks instead of
SProcXkbSetMap (presumably because walking the XkbSetMap request is hard,
and we don't want to maintain another copy of that code).
Swap the first time _XkbSetMapChecks is called, not the second time.
Signed-off-by: Peter Harris <pharris at opentext.com>
diff --git a/xkb/xkb.c b/xkb/xkb.c
index 3162574a4..9ffaf68fb 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -1587,7 +1587,7 @@ CheckKeyTypes(ClientPtr client,
XkbDescPtr xkb,
xkbSetMapReq * req,
xkbKeyTypeWireDesc ** wireRtrn,
- int *nMapsRtrn, CARD8 *mapWidthRtrn)
+ int *nMapsRtrn, CARD8 *mapWidthRtrn, Bool doswap)
{
unsigned nMaps;
register unsigned i, n;
@@ -1626,7 +1626,7 @@ CheckKeyTypes(ClientPtr client,
for (i = 0; i < req->nTypes; i++) {
unsigned width;
- if (client->swapped) {
+ if (client->swapped && doswap) {
swaps(&wire->virtualMods);
}
n = i + req->firstType;
@@ -1653,7 +1653,7 @@ CheckKeyTypes(ClientPtr client,
mapWire = (xkbKTSetMapEntryWireDesc *) &wire[1];
preWire = (xkbModsWireDesc *) &mapWire[wire->nMapEntries];
for (n = 0; n < wire->nMapEntries; n++) {
- if (client->swapped) {
+ if (client->swapped && doswap) {
swaps(&mapWire[n].virtualMods);
}
if (mapWire[n].realMods & (~wire->realMods)) {
@@ -1671,7 +1671,7 @@ CheckKeyTypes(ClientPtr client,
return 0;
}
if (wire->preserve) {
- if (client->swapped) {
+ if (client->swapped && doswap) {
swaps(&preWire[n].virtualMods);
}
if (preWire[n].realMods & (~mapWire[n].realMods)) {
@@ -1710,7 +1710,7 @@ CheckKeySyms(ClientPtr client,
xkbSetMapReq * req,
int nTypes,
CARD8 *mapWidths,
- CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn)
+ CARD16 *symsPerKey, xkbSymMapWireDesc ** wireRtrn, int *errorRtrn, Bool doswap)
{
register unsigned i;
XkbSymMapPtr map;
@@ -1724,7 +1724,7 @@ CheckKeySyms(ClientPtr client,
KeySym *pSyms;
register unsigned nG;
- if (client->swapped) {
+ if (client->swapped && doswap) {
swaps(&wire->nSyms);
}
nG = XkbNumGroups(wire->groupInfo);
@@ -2371,11 +2371,11 @@ SetVirtualModMap(XkbSrvInfoPtr xkbi,
/**
* Check if the given request can be applied to the given device but don't
- * actually do anything..
+ * actually do anything, except swap values when client->swapped and doswap are both true.
*/
static int
_XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req,
- char *values)
+ char *values, Bool doswap)
{
XkbSrvInfoPtr xkbi;
XkbDescPtr xkb;
@@ -2415,7 +2415,7 @@ _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req,
if ((req->present & XkbKeyTypesMask) &&
(!CheckKeyTypes(client, xkb, req, (xkbKeyTypeWireDesc **) &values,
- &nTypes, mapWidths))) {
+ &nTypes, mapWidths, doswap))) {
client->errorValue = nTypes;
return BadValue;
}
@@ -2439,7 +2439,7 @@ _XkbSetMapChecks(ClientPtr client, DeviceIntPtr dev, xkbSetMapReq * req,
if ((req->present & XkbKeySymsMask) &&
(!CheckKeySyms(client, xkb, req, nTypes, mapWidths, symsPerKey,
- (xkbSymMapWireDesc **) &values, &error))) {
+ (xkbSymMapWireDesc **) &values, &error, doswap))) {
client->errorValue = error;
return BadValue;
}
@@ -2631,7 +2631,7 @@ ProcXkbSetMap(ClientPtr client)
/* Check if we can to the SetMap on the requested device. If this
succeeds, do the same thing for all extension devices (if needed).
If any of them fails, fail. */
- rc = _XkbSetMapChecks(client, dev, stuff, tmp);
+ rc = _XkbSetMapChecks(client, dev, stuff, tmp, TRUE);
if (rc != Success)
return rc;
@@ -2647,7 +2647,7 @@ ProcXkbSetMap(ClientPtr client)
rc = XaceHook(XACE_DEVICE_ACCESS, client, other,
DixManageAccess);
if (rc == Success) {
- rc = _XkbSetMapChecks(client, other, stuff, tmp);
+ rc = _XkbSetMapChecks(client, other, stuff, tmp, FALSE);
if (rc != Success)
return rc;
}
@@ -2661,7 +2661,7 @@ ProcXkbSetMap(ClientPtr client)
(other != master || dev != master->lastSlave))
continue;
- rc = _XkbSetMapChecks(client, other, stuff, tmp);
+ rc = _XkbSetMapChecks(client, other, stuff, tmp, FALSE);
if (rc != Success)
return rc;
}
More information about the xorg-commit
mailing list