present: cap the version returned to the client

As per the protocol, the server should not return version greater than
the one supported by the client.

Add a spec quote and tweak the numbers accordingly.

Fixes: 5c5c1b7798 ("present: Add Present extension")
Cc: Thierry Reding <treding@nvidia.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
This commit is contained in:
Emil Velikov 2018-03-19 16:04:43 +00:00 committed by Adam Jackson
parent abb9b58d1a
commit 6a5d51e082
1 changed files with 13 additions and 1 deletions

View File

@ -41,7 +41,19 @@ proc_present_query_version(ClientPtr client)
};
REQUEST_SIZE_MATCH(xPresentQueryVersionReq);
(void) stuff;
/* From presentproto:
*
* The client sends the highest supported version to the server
* and the server sends the highest version it supports, but no
* higher than the requested version.
*/
if (rep.majorVersion > stuff->majorVersion ||
rep.minorVersion > stuff->minorVersion) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
}
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);