summaryrefslogtreecommitdiff
authorEamon Walsh <ewalsh@tycho.nsa.gov>2009-09-15 23:29:34 (GMT)
committer Eamon Walsh <ewalsh@tycho.nsa.gov>2009-10-15 00:58:23 (GMT)
commit2180174034ae007023f248964be315fccc3c32ee (patch) (side-by-side diff)
tree7f9396b707c860748323c1fc8c537fdc6ac901c9
parent439c58849304907900e4dc7429aedb0192749c02 (diff)
downloadxserver-2180174034ae007023f248964be315fccc3c32ee.zip
xserver-2180174034ae007023f248964be315fccc3c32ee.tar.gz
xace: Fake return values on denials in input polling requests.
Instead of returning BadAccess when "read" permission is denied on a device, falsify the device state (buttons down, keys pressed). This is nicer to applications, but may still have undesired side effects. The long-term solution is not to use these requests in event-driven code! Requests affected: QueryPointer, QueryKeymap, XiQueryDevice. [Backport to 1.6] Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Xi/queryst.c14
-rw-r--r--dix/devices.c5
-rw-r--r--dix/events.c11
3 files changed, 23 insertions, 7 deletions
diff --git a/Xi/queryst.c b/Xi/queryst.c
index 21de843..2d54020 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -96,7 +96,7 @@ ProcXQueryDeviceState(ClientPtr client)
rep.sequenceNumber = client->sequence;
rc = dixLookupDevice(&dev, stuff->deviceid, client, DixReadAccess);
- if (rc != Success)
+ if (rc != Success && rc != BadAccess)
return rc;
v = dev->valuator;
@@ -129,8 +129,9 @@ ProcXQueryDeviceState(ClientPtr client)
tk->class = KeyClass;
tk->length = sizeof(xKeyState);
tk->num_keys = k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode + 1;
- for (i = 0; i < 32; i++)
- tk->keys[i] = k->down[i];
+ if (rc != BadAccess)
+ for (i = 0; i < 32; i++)
+ tk->keys[i] = k->down[i];
buf += sizeof(xKeyState);
}
@@ -139,7 +140,8 @@ ProcXQueryDeviceState(ClientPtr client)
tb->class = ButtonClass;
tb->length = sizeof(xButtonState);
tb->num_buttons = b->numButtons;
- memcpy(tb->buttons, b->down, sizeof(b->down));
+ if (rc != BadAccess)
+ memcpy(tb->buttons, b->down, sizeof(b->down));
buf += sizeof(xButtonState);
}
@@ -151,7 +153,9 @@ ProcXQueryDeviceState(ClientPtr client)
tv->mode = v->mode;
buf += sizeof(xValuatorState);
for (i = 0, values = v->axisVal; i < v->numAxes; i++) {
- *((int *)buf) = *values++;
+ if (rc != BadAccess)
+ *((int *)buf) = *values;
+ values++;
if (client->swapped) {
swapl((int *)buf, n); /* macro - braces needed */
}
diff --git a/dix/devices.c b/dix/devices.c
index 3b8d544..9e3542d 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -2477,12 +2477,15 @@ ProcQueryKeymap(ClientPtr client)
rep.length = 2;
rc = XaceHook(XACE_DEVICE_ACCESS, client, keybd, DixReadAccess);
- if (rc != Success)
+ if (rc != Success && rc != BadAccess)
return rc;
for (i = 0; i<32; i++)
rep.map[i] = down[i];
+ if (rc == BadAccess)
+ memset(rep.map, 0, 32);
+
WriteReplyToClient(client, sizeof(xQueryKeymapReply), &rep);
return Success;
diff --git a/dix/events.c b/dix/events.c
index f9448ba..9b0ff55 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4771,7 +4771,7 @@ ProcQueryPointer(ClientPtr client)
if (rc != Success)
return rc;
rc = XaceHook(XACE_DEVICE_ACCESS, client, mouse, DixReadAccess);
- if (rc != Success)
+ if (rc != Success && rc != BadAccess)
return rc;
pSprite = mouse->spriteInfo->sprite;
@@ -4815,6 +4815,15 @@ ProcQueryPointer(ClientPtr client)
}
#endif
+ if (rc == BadAccess) {
+ rep.mask = 0;
+ rep.child = None;
+ rep.rootX = 0;
+ rep.rootY = 0;
+ rep.winX = 0;
+ rep.winY = 0;
+ }
+
WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
return(Success);