xfixes: Allow the client to upgrade the fixes protocol version

If you say FixesQueryVersion twice we remember whatever the second
version number was. With just libXfixes this isn't an issue because the
request is hidden in extension setup, but libxcb-xfixes doesn't do that
for you, which means the second one can _lower_ the requested fixes
version, disabling requests that the client thought it had enabled.

Paper over this by allowing the version number to be raised but not
lowered. Also go ahead and delete the minor version number from the
client state since xfixes doesn't have minor versions (yet, anyway).
This commit is contained in:
Adam Jackson 2021-06-22 12:39:56 -04:00 committed by Adam Jackson
parent 7d509b6f34
commit b2a0de4f07
2 changed files with 8 additions and 7 deletions

View File

@ -61,6 +61,7 @@ static DevPrivateKeyRec XFixesClientPrivateKeyRec;
static int
ProcXFixesQueryVersion(ClientPtr client)
{
int major, minor;
XFixesClientPtr pXFixesClient = GetXFixesClient(client);
xXFixesQueryVersionReply rep = {
.type = X_Reply,
@ -75,16 +76,17 @@ ProcXFixesQueryVersion(ClientPtr client)
if (version_compare(stuff->majorVersion, stuff->minorVersion,
SERVER_XFIXES_MAJOR_VERSION,
SERVER_XFIXES_MINOR_VERSION) < 0) {
rep.majorVersion = stuff->majorVersion;
rep.minorVersion = stuff->minorVersion;
major = max(pXFixesClient->major_version, stuff->majorVersion);
minor = stuff->minorVersion;
}
else {
rep.majorVersion = SERVER_XFIXES_MAJOR_VERSION;
rep.minorVersion = SERVER_XFIXES_MINOR_VERSION;
major = SERVER_XFIXES_MAJOR_VERSION;
minor = SERVER_XFIXES_MINOR_VERSION;
}
pXFixesClient->major_version = rep.majorVersion;
pXFixesClient->minor_version = rep.minorVersion;
pXFixesClient->major_version = major;
rep.majorVersion = min(stuff->majorVersion, major);
rep.minorVersion = minor;
if (client->swapped) {
swaps(&rep.sequenceNumber);
swapl(&rep.length);

View File

@ -64,7 +64,6 @@ extern int XFixesEventBase;
typedef struct _XFixesClient {
CARD32 major_version;
CARD32 minor_version;
} XFixesClientRec, *XFixesClientPtr;
#define GetXFixesClient(pClient) ((XFixesClientPtr)dixLookupPrivate(&(pClient)->devPrivates, XFixesClientPrivateKey))