diff options
Diffstat (limited to 'nx-X11/programs/Xserver')
-rw-r--r-- | nx-X11/programs/Xserver/dix/devices.c | 27 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/dix/dixfonts.c | 16 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/Keyboard.c | 8 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c | 33 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/os/io.c | 7 | ||||
-rw-r--r-- | nx-X11/programs/Xserver/xkb/xkb.c | 45 |
6 files changed, 64 insertions, 72 deletions
diff --git a/nx-X11/programs/Xserver/dix/devices.c b/nx-X11/programs/Xserver/dix/devices.c index 1c7572d64..51cf3fef9 100644 --- a/nx-X11/programs/Xserver/dix/devices.c +++ b/nx-X11/programs/Xserver/dix/devices.c @@ -908,7 +908,7 @@ AllModifierKeysAreUp(dev, map1, per1, map2, per2) int ProcSetModifierMapping(ClientPtr client) { - xSetModifierMappingReply rep; + xSetModifierMappingReply rep = {0}; REQUEST(xSetModifierMappingReq); KeyCode *inputMap; int inputMapLen; @@ -1016,11 +1016,10 @@ ProcSetModifierMapping(ClientPtr client) int ProcGetModifierMapping(ClientPtr client) { - xGetModifierMappingReply rep; + xGetModifierMappingReply rep = {0}; register KeyClassPtr keyc = inputInfo.keyboard->key; REQUEST_SIZE_MATCH(xReq); - memset(&rep, 0, sizeof(xGetModifierMappingReply)); rep.type = X_Reply; rep.numKeyPerModifier = keyc->maxKeysPerModifier; rep.sequenceNumber = client->sequence; @@ -1082,7 +1081,7 @@ ProcSetPointerMapping(ClientPtr client) { REQUEST(xSetPointerMappingReq); BYTE *map; - xSetPointerMappingReply rep; + xSetPointerMappingReply rep = {0}; register unsigned int i; DeviceIntPtr mouse = inputInfo.pointer; @@ -1119,7 +1118,7 @@ ProcSetPointerMapping(ClientPtr client) int ProcGetKeyboardMapping(ClientPtr client) { - xGetKeyboardMappingReply rep; + xGetKeyboardMappingReply rep = {0}; REQUEST(xGetKeyboardMappingReq); KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms; @@ -1138,7 +1137,6 @@ ProcGetKeyboardMapping(ClientPtr client) return BadValue; } - memset(&rep, 0, sizeof(xGetKeyboardMappingReply)); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.keySymsPerKeyCode = curKeySyms->mapWidth; @@ -1158,17 +1156,20 @@ ProcGetKeyboardMapping(ClientPtr client) int ProcGetPointerMapping(ClientPtr client) { + int nElts; xGetPointerMappingReply rep = {0}; ButtonClassPtr butc = inputInfo.pointer->button; + nElts = (butc) ? butc->numButtons : 0; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; + rep.nElts = nElts; rep.sequenceNumber = client->sequence; - rep.nElts = butc->numButtons; - rep.length = ((unsigned)rep.nElts + (4-1))/4; + rep.length = ((unsigned)nElts + (4-1))/4; WriteReplyToClient(client, sizeof(xGetPointerMappingReply), &rep); - WriteToClient(client, (int)rep.nElts, &butc->map[1]); + if (butc) + WriteToClient(client, nElts, &butc->map[1]); return Success; } @@ -1387,7 +1388,7 @@ ProcGetKeyboardControl (ClientPtr client) { int i; register KeybdCtrl *ctrl = &inputInfo.keyboard->kbdfeed->ctrl; - xGetKeyboardControlReply rep; + xGetKeyboardControlReply rep = {0}; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; @@ -1492,7 +1493,7 @@ int ProcGetPointerControl(ClientPtr client) { register PtrCtrl *ctrl = &inputInfo.pointer->ptrfeed->ctrl; - xGetPointerControlReply rep; + xGetPointerControlReply rep = {0}; REQUEST_SIZE_MATCH(xReq); rep.type = X_Reply; @@ -1526,7 +1527,7 @@ ProcGetMotionEvents(ClientPtr client) { WindowPtr pWin; xTimecoord * coords = (xTimecoord *) NULL; - xGetMotionEventsReply rep; + xGetMotionEventsReply rep = {0}; int i, count, xmin, xmax, ymin, ymax; unsigned long nEvents; DeviceIntPtr mouse = inputInfo.pointer; @@ -1591,7 +1592,7 @@ ProcGetMotionEvents(ClientPtr client) int ProcQueryKeymap(ClientPtr client) { - xQueryKeymapReply rep; + xQueryKeymapReply rep = {0}; int i; CARD8 *down = inputInfo.keyboard->key->down; diff --git a/nx-X11/programs/Xserver/dix/dixfonts.c b/nx-X11/programs/Xserver/dix/dixfonts.c index 0d90cd7b0..b16b6b2e6 100644 --- a/nx-X11/programs/Xserver/dix/dixfonts.c +++ b/nx-X11/programs/Xserver/dix/dixfonts.c @@ -741,7 +741,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) return TRUE; } if (err == FontNameAlias) { - if (resolved) free(resolved); + free(resolved); resolved = (char *) malloc(resolvedlen + 1); if (resolved) memmove(resolved, tmpname, resolvedlen + 1); @@ -807,8 +807,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) { c->saved = c->current; c->haveSaved = TRUE; - if (c->savedName) - free(c->savedName); + free(c->savedName); c->savedName = (char *)malloc(namelen + 1); if (c->savedName) memmove(c->savedName, name, namelen + 1); @@ -904,14 +903,14 @@ bail: for (i = 0; i < c->num_fpes; i++) FreeFPE(c->fpe_list[i]); free(c->fpe_list); - if (c->savedName) free(c->savedName); + free(c->savedName); #ifdef HAS_XFONT2 xfont2_free_font_names(names); #else FreeFontNames(names); #endif /* HAS_XFONT2 */ free(c); - if (resolved) free(resolved); + free(resolved); return TRUE; } @@ -931,7 +930,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, if (length > XLFDMAXFONTNAMELEN) return BadAlloc; - if (!(c = (LFclosurePtr) malloc(sizeof *c))) + if (!(c = (LFclosurePtr) calloc(1, sizeof *c))) return BadAlloc; c->fpe_list = (FontPathElementPtr *) malloc(sizeof(FontPathElementPtr) * num_fpes); @@ -1091,8 +1090,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) c->saved = c->current; c->haveSaved = TRUE; c->savedNumFonts = numFonts; - if (c->savedName) - free(c->savedName); + free(c->savedName); c->savedName = (char *)malloc(namelen + 1); if (c->savedName) memmove(c->savedName, name, namelen + 1); @@ -1203,7 +1201,7 @@ bail: FreeFPE(c->fpe_list[i]); free(c->reply); free(c->fpe_list); - if (c->savedName) free(c->savedName); + free(c->savedName); free(c); return TRUE; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c index 758ec9275..51a11b4f4 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c @@ -704,7 +704,7 @@ int nxagentKeyboardProc(DeviceIntPtr pDev, int onoff) int mapWidth; int min_keycode, max_keycode; KeySymsRec keySyms; - CARD8 modmap[256]; + CARD8 modmap[MAP_LENGTH]; int i, j; XKeyboardState values; char *model = NULL, *layout = NULL; @@ -765,7 +765,7 @@ N/A #ifdef _XSERVER64 { KeySym64 *keymap64; - int i, len; + int len; keymap64 = XGetKeyboardMapping(nxagentDisplay, min_keycode, max_keycode - min_keycode + 1, @@ -807,8 +807,7 @@ N/A nxagentCapsMask = 0; nxagentNumlockMask = 0; - for (i = 0; i < 256; i++) - modmap[i] = 0; + memset(modmap, 0, sizeof(modmap)); for (j = 0; j < 8; j++) for(i = 0; i < modifier_keymap->max_keypermod; i++) { CARD8 keycode; @@ -823,6 +822,7 @@ N/A } } XFreeModifiermap(modifier_keymap); + modifier_keymap = NULL; nxagentCheckRemoteKeycodes(); diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index e59144f94..50bf719c6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -361,7 +361,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) int nnames; int stringLens; int i; - xListFontsReply reply; + xListFontsReply reply = {0}; char *bufptr; char *bufferStart; int aliascount = 0; @@ -478,7 +478,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) return TRUE; } if (err == FontNameAlias) { - if (resolved) free(resolved); + free(resolved); resolved = (char *) malloc(resolvedlen + 1); if (resolved) memmove(resolved, tmpname, resolvedlen + 1); @@ -544,8 +544,7 @@ doListFontsAndAliases(ClientPtr client, LFclosurePtr c) { c->saved = c->current; c->haveSaved = TRUE; - if (c->savedName) - free(c->savedName); + free(c->savedName); c->savedName = (char *)malloc(namelen + 1); if (c->savedName) memmove(c->savedName, name, namelen + 1); @@ -602,13 +601,12 @@ finish: for (i = 0; i < nnames; i++) stringLens += (names->length[i] <= 255) ? names->length[i] : 0; - memset(&reply, 0, sizeof(xListFontsReply)); reply.type = X_Reply; reply.length = (stringLens + nnames + 3) >> 2; reply.nFonts = nnames; reply.sequenceNumber = client->sequence; - bufptr = bufferStart = (char *) malloc(reply.length << 2); + bufptr = bufferStart = (char *) calloc(1, reply.length << 2); if (!bufptr && reply.length) { SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc); @@ -664,14 +662,14 @@ bail: for (i = 0; i < c->num_fpes; i++) FreeFPE(c->fpe_list[i]); free(c->fpe_list); - if (c->savedName) free(c->savedName); + free(c->savedName); #ifdef HAS_XFONT2 xfont2_free_font_names(names); #else FreeFontNames(names); #endif /* HAS_XFONT2 */ free(c); - if (resolved) free(resolved); + free(resolved); return TRUE; } @@ -691,7 +689,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, if (length > XLFDMAXFONTNAMELEN) return BadAlloc; - if (!(c = (LFclosurePtr) malloc(sizeof *c))) + if (!(c = (LFclosurePtr) calloc(1, sizeof *c))) return BadAlloc; c->fpe_list = (FontPathElementPtr *) malloc(sizeof(FontPathElementPtr) * num_fpes); @@ -744,7 +742,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) xFontProp *pFP; int i; int aliascount = 0; - xListFontsWithInfoReply finalReply; + xListFontsWithInfoReply finalReply = {0}; if (client->clientGone) { @@ -857,8 +855,7 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) c->saved = c->current; c->haveSaved = TRUE; c->savedNumFonts = numFonts; - if (c->savedName) - free(c->savedName); + free(c->savedName); c->savedName = (char *)malloc(namelen + 1); if (c->savedName) memmove(c->savedName, name, namelen + 1); @@ -967,7 +964,6 @@ doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) } finish: length = sizeof(xListFontsWithInfoReply); - bzero((char *) &finalReply, sizeof(xListFontsWithInfoReply)); finalReply.type = X_Reply; finalReply.sequenceNumber = client->sequence; finalReply.length = (sizeof(xListFontsWithInfoReply) @@ -985,7 +981,7 @@ bail: FreeFPE(c->fpe_list[i]); free(c->reply); free(c->fpe_list); - if (c->savedName) free(c->savedName); + free(c->savedName); free(c); return TRUE; } @@ -1203,7 +1199,7 @@ nxdoListFontsAndAliases(client, fss) return TRUE; } if (err == FontNameAlias) { - if (resolved) free(resolved); + free(resolved); resolved = (char *) malloc(resolvedlen + 1); if (resolved) { @@ -1275,8 +1271,7 @@ nxdoListFontsAndAliases(client, fss) { c->saved = c->current; c->haveSaved = TRUE; - if (c->savedName) - free(c->savedName); + free(c->savedName); c->savedName = (char *)malloc(namelen + 1); if (c->savedName) { @@ -1372,7 +1367,7 @@ finish: for (i = 0; i < c->num_fpes; i++) FreeFPE(c->fpe_list[i]); free(c->fpe_list); - if (c->savedName) free(c->savedName); + free(c->savedName); #ifdef HAS_XFONT2 xfont2_free_font_names(c->names); #else @@ -1380,7 +1375,7 @@ finish: #endif /* HAS_XFONT2 */ free(c); free(fss); - if (resolved) free(resolved); + free(resolved); return doOpenFont(client, oc); } diff --git a/nx-X11/programs/Xserver/os/io.c b/nx-X11/programs/Xserver/os/io.c index 07399438e..6eeee349a 100644 --- a/nx-X11/programs/Xserver/os/io.c +++ b/nx-X11/programs/Xserver/os/io.c @@ -1120,7 +1120,12 @@ FlushClient(ClientPtr who, OsCommPtr oc, const void *__extraBuf, int extraCount) unsigned char *obuf = NULL; if (notWritten + BUFSIZE <= INT_MAX) { - obuf = realloc(oco->buf, notWritten + BUFSIZE); + obuf = calloc(1, notWritten + BUFSIZE); + if (obuf) + { + memmove(obuf, oco->buf, oco->size); + free(oco->buf); + } } if (!obuf) { diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index 8a96ec17d..987ebcd7b 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -159,7 +159,7 @@ int ProcXkbUseExtension(ClientPtr client) { REQUEST(xkbUseExtensionReq); - xkbUseExtensionReply rep; + xkbUseExtensionReply rep = {0}; int supported; REQUEST_SIZE_MATCH(xkbUseExtensionReq); @@ -187,7 +187,6 @@ ProcXkbUseExtension(ClientPtr client) stuff->wantedMajor,stuff->wantedMinor, SERVER_XKB_MAJOR_VERSION,SERVER_XKB_MINOR_VERSION); } - memset(&rep, 0, sizeof(xkbUseExtensionReply)); rep.type = X_Reply; rep.supported = supported; rep.length = 0; @@ -502,7 +501,7 @@ ProcXkbGetState(ClientPtr client) { REQUEST(xkbGetStateReq); DeviceIntPtr dev; - xkbGetStateReply rep; + xkbGetStateReply rep = {0}; XkbStateRec *xkb; REQUEST_SIZE_MATCH(xkbGetStateReq); @@ -513,7 +512,6 @@ ProcXkbGetState(ClientPtr client) CHK_KBD_DEVICE(dev,stuff->deviceSpec); xkb= &dev->key->xkbInfo->state; - bzero(&rep,sizeof(xkbGetStateReply)); rep.type= X_Reply; rep.sequenceNumber= client->sequence; rep.length = 0; @@ -1350,7 +1348,7 @@ int ProcXkbGetMap(ClientPtr client) { DeviceIntPtr dev; - xkbGetMapReply rep; + xkbGetMapReply rep = {0}; XkbDescRec *xkb; int n,status; @@ -1366,7 +1364,6 @@ ProcXkbGetMap(ClientPtr client) CHK_MASK_LEGAL(0x03,stuff->partial,XkbAllMapComponentsMask); xkb= dev->key->xkbInfo->desc; - bzero(&rep,sizeof(xkbGetMapReply)); rep.type= X_Reply; rep.sequenceNumber= client->sequence; rep.length = (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply))>>2; @@ -2542,7 +2539,7 @@ int size; int ProcXkbGetCompatMap(ClientPtr client) { - xkbGetCompatMapReply rep; + xkbGetCompatMapReply rep = {0}; DeviceIntPtr dev; XkbDescPtr xkb; XkbCompatMapPtr compat; @@ -2718,7 +2715,7 @@ ProcXkbSetCompatMap(ClientPtr client) int ProcXkbGetIndicatorState(ClientPtr client) { - xkbGetIndicatorStateReply rep; + xkbGetIndicatorStateReply rep = {0};; XkbSrvLedInfoPtr sli; DeviceIntPtr dev; @@ -2827,7 +2824,7 @@ register unsigned bit; int ProcXkbGetIndicatorMap(ClientPtr client) { -xkbGetIndicatorMapReply rep; + xkbGetIndicatorMapReply rep = {0}; DeviceIntPtr dev; XkbDescPtr xkb; XkbIndicatorPtr leds; @@ -2937,7 +2934,7 @@ int ProcXkbGetNamedIndicator(ClientPtr client) { DeviceIntPtr dev; - xkbGetNamedIndicatorReply rep; + xkbGetNamedIndicatorReply rep = {0}; register int i = 0; XkbSrvLedInfoPtr sli; XkbIndicatorMapPtr map = NULL; @@ -3438,7 +3435,7 @@ ProcXkbGetNames(ClientPtr client) { DeviceIntPtr dev; XkbDescPtr xkb; - xkbGetNamesReply rep; + xkbGetNamesReply rep = {0}; REQUEST(xkbGetNamesReq); REQUEST_SIZE_MATCH(xkbGetNamesReq); @@ -3450,7 +3447,6 @@ ProcXkbGetNames(ClientPtr client) CHK_MASK_LEGAL(0x01,stuff->which,XkbAllNamesMask); xkb = dev->key->xkbInfo->desc; - memset(&rep, 0, sizeof(xkbGetNamesReply)); rep.type= X_Reply; rep.sequenceNumber= client->sequence; rep.length = 0; @@ -4368,7 +4364,7 @@ int ProcXkbGetGeometry(ClientPtr client) { DeviceIntPtr dev; - xkbGetGeometryReply rep; + xkbGetGeometryReply rep = {0}; XkbGeometryPtr geom; Bool shouldFree; Status status; @@ -4907,7 +4903,7 @@ int ProcXkbPerClientFlags(ClientPtr client) { DeviceIntPtr dev; - xkbPerClientFlagsReply rep; + xkbPerClientFlagsReply rep = {0}; XkbInterestPtr interest; REQUEST(xkbPerClientFlagsReq); @@ -4921,7 +4917,6 @@ ProcXkbPerClientFlags(ClientPtr client) CHK_MASK_MATCH(0x02,stuff->change,stuff->value); interest = XkbFindClientResource((DevicePtr)dev,client); - memset(&rep, 0, sizeof(xkbPerClientFlagsReply)); rep.type= X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; @@ -5040,7 +5035,7 @@ int ProcXkbListComponents(ClientPtr client) { DeviceIntPtr dev; - xkbListComponentsReply rep; + xkbListComponentsReply rep = {0}; unsigned len; int status; unsigned char * str; @@ -5076,7 +5071,6 @@ ProcXkbListComponents(ClientPtr client) } return status; } - bzero(&rep,sizeof(xkbListComponentsReply)); rep.type= X_Reply; rep.deviceID = dev->id; rep.sequenceNumber = client->sequence; @@ -5117,12 +5111,12 @@ ProcXkbGetKbdByName(ClientPtr client) { DeviceIntPtr dev; XkbFileInfo finfo; - xkbGetKbdByNameReply rep; - xkbGetMapReply mrep; - xkbGetCompatMapReply crep; - xkbGetIndicatorMapReply irep; - xkbGetNamesReply nrep; - xkbGetGeometryReply grep; + xkbGetKbdByNameReply rep = {0}; + xkbGetMapReply mrep = {0}; + xkbGetCompatMapReply crep = {0}; + xkbGetIndicatorMapReply irep = {0}; + xkbGetNamesReply nrep = {0}; + xkbGetGeometryReply grep = {0}; XkbComponentNamesRec names; XkbDescPtr xkb; unsigned char * str; @@ -5641,7 +5635,7 @@ int ProcXkbGetDeviceInfo(ClientPtr client) { DeviceIntPtr dev; -xkbGetDeviceInfoReply rep; +xkbGetDeviceInfoReply rep = {0}; int status,nDeviceLedFBs; unsigned length,nameLen; CARD16 ledClass,ledID; @@ -5666,7 +5660,6 @@ char * str; wanted&= ~XkbXIUnsupported; nameLen= XkbSizeCountedString(dev->name); - bzero((char *)&rep,SIZEOF(xkbGetDeviceInfoReply)); rep.type = X_Reply; rep.deviceID= dev->id; rep.sequenceNumber = client->sequence; @@ -6059,7 +6052,7 @@ int ProcXkbSetDebuggingFlags(ClientPtr client) { CARD32 newFlags,newCtrls,extraLength; -xkbSetDebuggingFlagsReply rep; +xkbSetDebuggingFlagsReply rep = {0}; REQUEST(xkbSetDebuggingFlagsReq); REQUEST_AT_LEAST_SIZE(xkbSetDebuggingFlagsReq); |