summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
authorMichal Srb <msrb@suse.com>2017-07-07 17:21:46 +0200
committerAdam Jackson <ajax@redhat.com>2017-09-25 15:34:10 -0400
commit6f29c8375281c0337ab94f7919a70c20149b0fc6 (patch)
treea00d3d7d5728ad4c9042a7ee04ecf633468b7884 /Xi
parentc8eb79c1834cef5657e227844111052e0dd78661 (diff)
Xi: Test exact size of XIBarrierReleasePointer
Otherwise a client can send any value of num_barriers and cause reading or swapping of values on heap behind the receive buffer. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> (cherry picked from commit 211e05ac85a294ef361b9f80d689047fa52b9076)
Diffstat (limited to 'Xi')
-rw-r--r--Xi/xibarriers.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Xi/xibarriers.c b/Xi/xibarriers.c
index a8b92cc18..0bc5761f3 100644
--- a/Xi/xibarriers.c
+++ b/Xi/xibarriers.c
@@ -830,10 +830,13 @@ SProcXIBarrierReleasePointer(ClientPtr client)
REQUEST(xXIBarrierReleasePointerReq);
int i;
- info = (xXIBarrierReleasePointerInfo*) &stuff[1];
-
swaps(&stuff->length);
+ REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq);
+
swapl(&stuff->num_barriers);
+ REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
+
+ info = (xXIBarrierReleasePointerInfo*) &stuff[1];
for (i = 0; i < stuff->num_barriers; i++, info++) {
swaps(&info->deviceid);
swapl(&info->barrier);
@@ -853,7 +856,7 @@ ProcXIBarrierReleasePointer(ClientPtr client)
xXIBarrierReleasePointerInfo *info;
REQUEST(xXIBarrierReleasePointerReq);
- REQUEST_AT_LEAST_SIZE(xXIBarrierReleasePointerReq);
+ REQUEST_FIXED_SIZE(xXIBarrierReleasePointerReq, stuff->num_barriers * sizeof(xXIBarrierReleasePointerInfo));
info = (xXIBarrierReleasePointerInfo*) &stuff[1];
for (i = 0; i < stuff->num_barriers; i++, info++) {