dri3: 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: 5631382988 ("dri3: Add DRI3 extension")
Cc: Daniel Stone <daniels@collabora.com>
Cc: Keith Packard <keithp@keithp.com>
Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
Emil Velikov 2018-03-13 18:38:49 +00:00 committed by Adam Jackson
parent 6a5d51e082
commit ae5c0dd199
1 changed files with 13 additions and 1 deletions

View File

@ -45,7 +45,19 @@ proc_dri3_query_version(ClientPtr client)
};
REQUEST_SIZE_MATCH(xDRI3QueryVersionReq);
(void) stuff;
/* From DRI3 proto:
*
* 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);