XKB: Remove usage of alloca
alloca has no way to return failure, and instead can possibly arbitrarily overflow the stack. Let's avoid that one.
This commit is contained in:
parent
6e4f5cf83f
commit
59774af86b
24
xkb/xkb.c
24
xkb/xkb.c
|
@ -1312,7 +1312,7 @@ unsigned i,len;
|
||||||
char *desc,*start;
|
char *desc,*start;
|
||||||
|
|
||||||
len= (rep->length*4)-(SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply));
|
len= (rep->length*4)-(SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply));
|
||||||
start= desc= (char *)ALLOCATE_LOCAL(len);
|
start= desc= (char *)xalloc(len);
|
||||||
if (!start)
|
if (!start)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
if ( rep->nTypes>0 )
|
if ( rep->nTypes>0 )
|
||||||
|
@ -1352,7 +1352,7 @@ char *desc,*start;
|
||||||
}
|
}
|
||||||
WriteToClient(client, (i=SIZEOF(xkbGetMapReply)), (char *)rep);
|
WriteToClient(client, (i=SIZEOF(xkbGetMapReply)), (char *)rep);
|
||||||
WriteToClient(client, len, start);
|
WriteToClient(client, len, start);
|
||||||
DEALLOCATE_LOCAL((char *)start);
|
xfree((char *)start);
|
||||||
return client->noClientException;
|
return client->noClientException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2499,7 +2499,7 @@ int size;
|
||||||
|
|
||||||
size= rep->length*4;
|
size= rep->length*4;
|
||||||
if (size>0) {
|
if (size>0) {
|
||||||
data = (char *)ALLOCATE_LOCAL(size);
|
data = (char *)xalloc(size);
|
||||||
if (data) {
|
if (data) {
|
||||||
register unsigned i,bit;
|
register unsigned i,bit;
|
||||||
xkbModsWireDesc * grp;
|
xkbModsWireDesc * grp;
|
||||||
|
@ -2550,7 +2550,7 @@ int size;
|
||||||
WriteToClient(client, SIZEOF(xkbGetCompatMapReply), (char *)rep);
|
WriteToClient(client, SIZEOF(xkbGetCompatMapReply), (char *)rep);
|
||||||
if (data) {
|
if (data) {
|
||||||
WriteToClient(client, size, data);
|
WriteToClient(client, size, data);
|
||||||
DEALLOCATE_LOCAL((char *)data);
|
xfree((char *)data);
|
||||||
}
|
}
|
||||||
return client->noClientException;
|
return client->noClientException;
|
||||||
}
|
}
|
||||||
|
@ -2801,7 +2801,7 @@ register unsigned bit;
|
||||||
length = rep->length*4;
|
length = rep->length*4;
|
||||||
if (length>0) {
|
if (length>0) {
|
||||||
CARD8 *to;
|
CARD8 *to;
|
||||||
to= map= (CARD8 *)ALLOCATE_LOCAL(length);
|
to= map= (CARD8 *)xalloc(length);
|
||||||
if (map) {
|
if (map) {
|
||||||
xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *)to;
|
xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *)to;
|
||||||
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
|
for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
|
||||||
|
@ -2840,7 +2840,7 @@ register unsigned bit;
|
||||||
WriteToClient(client, SIZEOF(xkbGetIndicatorMapReply), (char *)rep);
|
WriteToClient(client, SIZEOF(xkbGetIndicatorMapReply), (char *)rep);
|
||||||
if (map) {
|
if (map) {
|
||||||
WriteToClient(client, length, (char *)map);
|
WriteToClient(client, length, (char *)map);
|
||||||
DEALLOCATE_LOCAL((char *)map);
|
xfree((char *)map);
|
||||||
}
|
}
|
||||||
return client->noClientException;
|
return client->noClientException;
|
||||||
}
|
}
|
||||||
|
@ -3292,7 +3292,7 @@ register int n;
|
||||||
swapl(&rep->indicators,n);
|
swapl(&rep->indicators,n);
|
||||||
}
|
}
|
||||||
|
|
||||||
start = desc = (char *)ALLOCATE_LOCAL(length);
|
start = desc = (char *)xalloc(length);
|
||||||
if ( !start )
|
if ( !start )
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
if (xkb->names) {
|
if (xkb->names) {
|
||||||
|
@ -3416,7 +3416,7 @@ register int n;
|
||||||
}
|
}
|
||||||
WriteToClient(client, SIZEOF(xkbGetNamesReply), (char *)rep);
|
WriteToClient(client, SIZEOF(xkbGetNamesReply), (char *)rep);
|
||||||
WriteToClient(client, length, start);
|
WriteToClient(client, length, start);
|
||||||
DEALLOCATE_LOCAL((char *)start);
|
xfree((char *)start);
|
||||||
return client->noClientException;
|
return client->noClientException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4314,7 +4314,7 @@ XkbSendGeometry( ClientPtr client,
|
||||||
|
|
||||||
if (geom!=NULL) {
|
if (geom!=NULL) {
|
||||||
len= rep->length*4;
|
len= rep->length*4;
|
||||||
start= desc= (char *)ALLOCATE_LOCAL(len);
|
start= desc= (char *)xalloc(len);
|
||||||
if (!start)
|
if (!start)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
desc= XkbWriteCountedString(desc,geom->label_font,client->swapped);
|
desc= XkbWriteCountedString(desc,geom->label_font,client->swapped);
|
||||||
|
@ -4358,7 +4358,7 @@ XkbSendGeometry( ClientPtr client,
|
||||||
if (len>0)
|
if (len>0)
|
||||||
WriteToClient(client, len, start);
|
WriteToClient(client, len, start);
|
||||||
if (start!=NULL)
|
if (start!=NULL)
|
||||||
DEALLOCATE_LOCAL((char *)start);
|
xfree((char *)start);
|
||||||
if (freeGeom)
|
if (freeGeom)
|
||||||
XkbFreeGeometry(geom,XkbGeomAllMask,True);
|
XkbFreeGeometry(geom,XkbGeomAllMask,True);
|
||||||
return client->noClientException;
|
return client->noClientException;
|
||||||
|
@ -5758,12 +5758,12 @@ char * str;
|
||||||
}
|
}
|
||||||
WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep);
|
WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), (char *)&rep);
|
||||||
|
|
||||||
str= (char*) ALLOCATE_LOCAL(nameLen);
|
str= (char*) xalloc(nameLen);
|
||||||
if (!str)
|
if (!str)
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
XkbWriteCountedString(str,dev->name,client->swapped);
|
XkbWriteCountedString(str,dev->name,client->swapped);
|
||||||
WriteToClient(client,nameLen,str);
|
WriteToClient(client,nameLen,str);
|
||||||
DEALLOCATE_LOCAL(str);
|
xfree(str);
|
||||||
length-= nameLen;
|
length-= nameLen;
|
||||||
|
|
||||||
if (rep.nBtnsRtrn>0) {
|
if (rep.nBtnsRtrn>0) {
|
||||||
|
|
|
@ -182,7 +182,7 @@ char * pval;
|
||||||
ErrorF("Atom error: %s not created\n",_XKB_RF_NAMES_PROP_ATOM);
|
ErrorF("Atom error: %s not created\n",_XKB_RF_NAMES_PROP_ATOM);
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
pval= (char*) ALLOCATE_LOCAL(len);
|
pval= (char*) xalloc(len);
|
||||||
if (!pval) {
|
if (!pval) {
|
||||||
ErrorF("Allocation error: %s proprerty not created\n",
|
ErrorF("Allocation error: %s proprerty not created\n",
|
||||||
_XKB_RF_NAMES_PROP_ATOM);
|
_XKB_RF_NAMES_PROP_ATOM);
|
||||||
|
@ -223,7 +223,7 @@ char * pval;
|
||||||
}
|
}
|
||||||
ChangeWindowProperty(WindowTable[0],name,XA_STRING,8,PropModeReplace,
|
ChangeWindowProperty(WindowTable[0],name,XA_STRING,8,PropModeReplace,
|
||||||
len,pval,True);
|
len,pval,True);
|
||||||
DEALLOCATE_LOCAL(pval);
|
xfree(pval);
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue