Commit 1357af24 authored by Daniel Stone's avatar Daniel Stone

Coverity #340: Fix potential NULL dereference. Clean up proliferation of

    'register int n' in loops of ProcXkbGetNames.
parent f324be00
......@@ -9,6 +9,10 @@
* xkb/XKBMAlloc.c:
Coverity #324: Fix potential NULL dereference. (Alan Coopersmith)
* xkb/xkb.c:
Coverity #340: Fix potential NULL dereference.
Clean up proliferation of 'register int n' in loops of ProcXkbGetNames.
2006-04-07 Aaron Plattner <aplattner@nvidia.com>
* hw/xfree86/common/xf86Module.h:
......
......@@ -3121,7 +3121,8 @@ ProcXkbSetNamedIndicator(ClientPtr client)
if (!stuff->createMap)
return client->noClientException;
for (led=0,map=NULL;(led<XkbNumIndicators)&&(map==NULL);led++) {
if ((sli->names[led]==None)&&(!XkbIM_InUse(&sli->maps[led]))) {
if ((sli->names)&&(sli->leds)&&(sli->names[led]==None)&&
(!XkbIM_InUse(&sli->maps[led]))) {
map= &sli->maps[led];
sli->names[led]= stuff->indicator;
break;
......@@ -3317,11 +3318,11 @@ XkbSendNames(ClientPtr client,XkbDescPtr xkb,xkbGetNamesReply *rep)
register unsigned i,length,which;
char * start;
char * desc;
register int n;
length= rep->length*4;
which= rep->which;
if (client->swapped) {
register int n;
swaps(&rep->sequenceNumber,n);
swapl(&rep->length,n);
swapl(&rep->which,n);
......@@ -3332,127 +3333,121 @@ char * desc;
start = desc = (char *)ALLOCATE_LOCAL(length);
if ( !start )
return BadAlloc;
if (which&XkbKeycodesNameMask) {
*((CARD32 *)desc)= xkb->names->keycodes;
if (client->swapped) {
register int n;
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbGeometryNameMask) {
*((CARD32 *)desc)= xkb->names->geometry;
if (client->swapped) {
register int n;
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbSymbolsNameMask) {
*((CARD32 *)desc)= xkb->names->symbols;
if (client->swapped) {
register int n;
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbPhysSymbolsNameMask) {
register CARD32 *atm= (CARD32 *)desc;
atm[0]= (CARD32)xkb->names->phys_symbols;
if (client->swapped) {
register int n;
swapl(&atm[0],n);
}
desc+= 4;
}
if (which&XkbTypesNameMask) {
*((CARD32 *)desc)= (CARD32)xkb->names->types;
if (client->swapped) {
register int n;
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbCompatNameMask) {
*((CARD32 *)desc)= (CARD32)xkb->names->compat;
if (client->swapped) {
register int n;
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbKeyTypeNamesMask) {
register CARD32 *atm= (CARD32 *)desc;
register XkbKeyTypePtr type= xkb->map->types;
for (i=0;i<xkb->map->num_types;i++,atm++,type++) {
*atm= (CARD32)type->name;
if (client->swapped) {
register int n;
swapl(atm,n);
}
}
desc= (char *)atm;
if (xkb->names) {
if (which&XkbKeycodesNameMask) {
*((CARD32 *)desc)= xkb->names->keycodes;
if (client->swapped) {
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbGeometryNameMask) {
*((CARD32 *)desc)= xkb->names->geometry;
if (client->swapped) {
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbSymbolsNameMask) {
*((CARD32 *)desc)= xkb->names->symbols;
if (client->swapped) {
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbPhysSymbolsNameMask) {
register CARD32 *atm= (CARD32 *)desc;
atm[0]= (CARD32)xkb->names->phys_symbols;
if (client->swapped) {
swapl(&atm[0],n);
}
desc+= 4;
}
if (which&XkbTypesNameMask) {
*((CARD32 *)desc)= (CARD32)xkb->names->types;
if (client->swapped) {
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbCompatNameMask) {
*((CARD32 *)desc)= (CARD32)xkb->names->compat;
if (client->swapped) {
swapl(desc,n);
}
desc+= 4;
}
if (which&XkbKeyTypeNamesMask) {
register CARD32 *atm= (CARD32 *)desc;
register XkbKeyTypePtr type= xkb->map->types;
for (i=0;i<xkb->map->num_types;i++,atm++,type++) {
*atm= (CARD32)type->name;
if (client->swapped) {
swapl(atm,n);
}
}
desc= (char *)atm;
}
if (which&XkbKTLevelNamesMask && xkb->map) {
XkbKeyTypePtr type = xkb->map->types;
register CARD32 *atm;
for (i=0;i<rep->nTypes;i++,type++) {
*desc++ = type->num_levels;
}
desc+= XkbPaddedSize(rep->nTypes)-rep->nTypes;
atm= (CARD32 *)desc;
type = xkb->map->types;
for (i=0;i<xkb->map->num_types;i++,type++) {
register unsigned l;
if (type->level_names) {
for (l=0;l<type->num_levels;l++,atm++) {
*atm= type->level_names[l];
if (client->swapped) {
swapl(atm,n);
}
}
desc+= type->num_levels*4;
}
}
}
if (which&XkbIndicatorNamesMask) {
desc= _XkbWriteAtoms(desc,xkb->names->indicators,XkbNumIndicators,
client->swapped);
}
if (which&XkbVirtualModNamesMask) {
desc= _XkbWriteAtoms(desc,xkb->names->vmods,XkbNumVirtualMods,
client->swapped);
}
if (which&XkbGroupNamesMask) {
desc= _XkbWriteAtoms(desc,xkb->names->groups,XkbNumKbdGroups,
client->swapped);
}
if (which&XkbKeyNamesMask) {
for (i=0;i<rep->nKeys;i++,desc+= sizeof(XkbKeyNameRec)) {
*((XkbKeyNamePtr)desc)= xkb->names->keys[i+rep->firstKey];
}
}
if (which&XkbKeyAliasesMask) {
XkbKeyAliasPtr pAl;
pAl= xkb->names->key_aliases;
for (i=0;i<rep->nKeyAliases;i++,pAl++,desc+=2*XkbKeyNameLength) {
*((XkbKeyAliasPtr)desc)= *pAl;
}
}
if ((which&XkbRGNamesMask)&&(rep->nRadioGroups>0)) {
register CARD32 *atm= (CARD32 *)desc;
for (i=0;i<rep->nRadioGroups;i++,atm++) {
*atm= (CARD32)xkb->names->radio_groups[i];
if (client->swapped) {
swapl(atm,n);
}
}
desc+= rep->nRadioGroups*4;
}
}
if (which&XkbKTLevelNamesMask) {
XkbKeyTypePtr type = xkb->map->types;
register CARD32 *atm;
for (i=0;i<rep->nTypes;i++,type++) {
*desc++ = type->num_levels;
}
desc+= XkbPaddedSize(rep->nTypes)-rep->nTypes;
atm= (CARD32 *)desc;
type = xkb->map->types;
for (i=0;i<xkb->map->num_types;i++,type++) {
register unsigned l;
if (type->level_names) {
for (l=0;l<type->num_levels;l++,atm++) {
*atm= type->level_names[l];
if (client->swapped) {
register unsigned n;
swapl(atm,n);
}
}
desc+= type->num_levels*4;
}
}
}
if (which&XkbIndicatorNamesMask) {
desc= _XkbWriteAtoms(desc,xkb->names->indicators,XkbNumIndicators,
client->swapped);
}
if (which&XkbVirtualModNamesMask) {
desc= _XkbWriteAtoms(desc,xkb->names->vmods,XkbNumVirtualMods,
client->swapped);
}
if (which&XkbGroupNamesMask) {
desc= _XkbWriteAtoms(desc,xkb->names->groups,XkbNumKbdGroups,
client->swapped);
}
if (which&XkbKeyNamesMask) {
for (i=0;i<rep->nKeys;i++,desc+= sizeof(XkbKeyNameRec)) {
*((XkbKeyNamePtr)desc)= xkb->names->keys[i+rep->firstKey];
}
}
if (which&XkbKeyAliasesMask) {
XkbKeyAliasPtr pAl;
pAl= xkb->names->key_aliases;
for (i=0;i<rep->nKeyAliases;i++,pAl++,desc+=2*XkbKeyNameLength) {
*((XkbKeyAliasPtr)desc)= *pAl;
}
}
if ((which&XkbRGNamesMask)&&(rep->nRadioGroups>0)) {
register CARD32 *atm= (CARD32 *)desc;
for (i=0;i<rep->nRadioGroups;i++,atm++) {
*atm= (CARD32)xkb->names->radio_groups[i];
if (client->swapped) {
register unsigned n;
swapl(atm,n);
}
}
desc+= rep->nRadioGroups*4;
}
if ((desc-start)!=(length)) {
ErrorF("BOGUS LENGTH in write names, expected %d, got %ld\n",
length, (unsigned long)(desc-start));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment