static int swap_auth(ClientPtr client, pointer data, int num, int length) { unsigned char *p; unsigned char t; CARD16 namelen, datalen; int i; p = data; for (i = 0; i < num; i++) { if (p - (unsigned char *)data > length - 4) { int lengthword = length; SendErrToClient(client, FSBadLength, (pointer)&lengthword); return (FSBadLength); } namelen = *(CARD16 *) p; t = p[0]; p[0] = p[1]; p[1] = t; p += 2; datalen = *(CARD16 *) p; t = p[0]; p[0] = p[1]; p[1] = t; p += 2; p += (namelen + 3) & ~3; p += (datalen + 3) & ~3; } if (!num) p += 4; if (p - (unsigned char *)data != length) { int lengthword = length; SendErrToClient(client, FSBadLength, (pointer)&lengthword); return (FSBadLength); } return (FSSuccess); }
int ProcListExtensions(ClientPtr client) { fsListExtensionsReply reply; char *bufptr, *buffer; int total_length = 0; REQUEST(fsListExtensionsReq); REQUEST_SIZE_MATCH(fsListExtensionsReq); reply.type = FS_Reply; reply.nExtensions = NumExtensions; reply.length = SIZEOF(fsListExtensionsReply) >> 2; reply.sequenceNumber = client->sequence; buffer = NULL; if (NumExtensions) { int i, j; for (i = 0; i < NumExtensions; i++) { total_length += strlen(extensions[i]->name) + 1; reply.nExtensions += extensions[i]->num_aliases; for (j = extensions[i]->num_aliases; --j >= 0;) total_length += strlen(extensions[i]->aliases[j]) + 1; } reply.length += (total_length + 3) >> 2; buffer = bufptr = (char *) ALLOCATE_LOCAL(total_length); if (!buffer) { SendErrToClient(client, FSBadAlloc, NULL); return FSBadAlloc; } for (i = 0; i < NumExtensions; i++) { int len; *bufptr++ = len = strlen(extensions[i]->name); memmove( bufptr, extensions[i]->name, len); bufptr += len; for (j = extensions[i]->num_aliases; --j >= 0;) { *bufptr++ = len = strlen(extensions[i]->aliases[j]); memmove( bufptr, extensions[i]->aliases[j], len); bufptr += len; } } } WriteReplyToClient(client, SIZEOF(fsListExtensionsReply), &reply); if (total_length) { WriteToClient(client, total_length, buffer); DEALLOCATE_LOCAL(buffer); } return client->noClientException; }
int ProcSetEventMask(ClientPtr client) { REQUEST(fsSetEventMaskReq); REQUEST_AT_LEAST_SIZE(fsSetEventMaskReq); if (stuff->event_mask & ~AllEventMasks) { SendErrToClient(client, FSBadEventMask, (pointer) &stuff->event_mask); return FSBadEventMask; } client->eventmask = stuff->event_mask; return client->noClientException; }