From 030b441e21ac76ad5f566194a687e36432363717 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 10 Mar 2025 14:12:48 +0100 Subject: [PATCH] dix: resource: protect FakeClientID() from returning 0 Some callers treating XID = 0 as a sign for non-existing resource. Practically should not happen, but nevertheless adding extra protection, just in case. Signed-off-by: Enrico Weigelt, metux IT consult --- dix/resource.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dix/resource.c b/dix/resource.c index 3b3453b17..149cf0bc9 100644 --- a/dix/resource.c +++ b/dix/resource.c @@ -789,6 +789,12 @@ FakeClientID(int client) XID id, maxid; id = clientTable[client].fakeID++; + + // extra paranoid protection, because many places expect 0 as + // sign for resource not existing + if (!id) + return FakeClientID(client); + if (id != clientTable[client].endFakeID) return id; GetXIDRange(client, TRUE, &id, &maxid); @@ -801,6 +807,10 @@ FakeClientID(int client) } clientTable[client].fakeID = id + 1; clientTable[client].endFakeID = maxid + 1; + + if (!id) + return FakeClientID(client); + return id; }