From e4c768dc09a62c104e66834b698eae63aafd1af9 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Thu, 7 Aug 2025 20:22:01 +0200 Subject: [PATCH] HACK WriteRpcbufToClient --- dix/extension.c | 39 +++++++++++++++++++++------------------ os/io.c | 1 + 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/dix/extension.c b/dix/extension.c index 131885148..5820c715a 100644 --- a/dix/extension.c +++ b/dix/extension.c @@ -68,7 +68,7 @@ static ExtensionEntry **extensions = (ExtensionEntry **) NULL; int lastEvent = EXTENSION_EVENT_BASE; static int lastError = FirstExtensionError; -static unsigned int NumExtensions = RESERVED_EXTENSIONS; +static size_t NumExtensions = RESERVED_EXTENSIONS; static struct { const char *name; int id; } reservedExt[] = { { "BIG-REQUESTS", EXTENSION_MAJOR_BIG_REQUESTS }, @@ -111,7 +111,7 @@ static struct { const char *name; int id; } reservedExt[] = { static int checkReserved(const char* name) { - for (int i=0; iname) goto badalloc; - int i = checkReserved(ext->name); - if (i == -1) { - i = NumExtensions; - ExtensionEntry **newexts = reallocarray(extensions, i + 1, sizeof(ExtensionEntry *)); + int ret = checkReserved(ext->name); + size_t idx; + if (ret < 0) { + idx = NumExtensions; + ExtensionEntry **newexts = reallocarray(extensions, idx + 1, sizeof(ExtensionEntry *)); if (!newexts) goto badalloc; NumExtensions++; extensions = newexts; } else { - i = i - EXTENSION_BASE; + /* ret is always >= EXTENSION_BASE */ + idx = (size_t) ret - EXTENSION_BASE; } - extensions[i] = ext; - ext->index = i; - ext->base = i + EXTENSION_BASE; + extensions[idx] = ext; + ext->index = (int)idx; + ext->base = (int)idx + EXTENSION_BASE; ext->CloseDown = CloseDownProc; ext->MinorOpcode = MinorOpcodeProc; - ProcVector[i + EXTENSION_BASE] = MainProc; - SwappedProcVector[i + EXTENSION_BASE] = SwappedMainProc; + ProcVector[idx + EXTENSION_BASE] = MainProc; + SwappedProcVector[idx + EXTENSION_BASE] = SwappedMainProc; if (NumEvents) { ext->eventBase = lastEvent; ext->eventLast = lastEvent + NumEvents; @@ -214,7 +216,7 @@ CheckExtension(const char *extname) if (!extensions) return NULL; - for (int i = 0; i < NumExtensions; i++) { + for (size_t i = 0; i < NumExtensions; i++) { if (extensions[i] && extensions[i]->name && strcmp(extensions[i]->name, extname) == 0) { @@ -228,8 +230,9 @@ CheckExtension(const char *extname) * Added as part of Xace. */ ExtensionEntry * -GetExtensionEntry(int major) +GetExtensionEntry(int imajor) { + size_t major = (size_t)imajor; if ((major < EXTENSION_BASE) || !extensions) return NULL; major -= EXTENSION_BASE; @@ -250,7 +253,7 @@ CloseDownExtensions(void) if (!extensions) return; - for (int i = NumExtensions - 1; i >= 0; i--) { + for (size_t i = NumExtensions - 1; i >= 0; i--) { if (!extensions[i]) continue; if (extensions[i]->CloseDown) @@ -313,7 +316,7 @@ int ProcListExtensions(ClientPtr client) { char *bufptr, *buffer; - int total_length = 0; + size_t total_length = 0; REQUEST_SIZE_MATCH(xReq); @@ -326,7 +329,7 @@ ProcListExtensions(ClientPtr client) buffer = NULL; if (NumExtensions && extensions) { - for (int i = 0; i < NumExtensions; i++) { + for (size_t i = 0; i < NumExtensions; i++) { /* call callbacks to find out whether to show extension */ if (!ExtensionAvailable(client, extensions[i])) continue; @@ -338,7 +341,7 @@ ProcListExtensions(ClientPtr client) buffer = bufptr = calloc(1, total_length); if (!buffer) return BadAlloc; - for (int i = 0; i < NumExtensions; i++) { + for (size_t i = 0; i < NumExtensions; i++) { int len; if (!ExtensionAvailable(client, extensions[i])) diff --git a/os/io.c b/os/io.c index 9c53cc7e6..dd70d3a8c 100644 --- a/os/io.c +++ b/os/io.c @@ -768,6 +768,7 @@ OutputBufferMakeRoomAndFlush(ClientPtr who, OsCommPtr oc, const void* extra_buf, * this routine as int. *****************/ +// make this ssize_t int WriteToClient(ClientPtr who, int count, const void *__buf) {