aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/Xext
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/Xext')
-rw-r--r--xorg-server/Xext/hashtable.c4
-rw-r--r--xorg-server/Xext/panoramiX.c10
-rw-r--r--xorg-server/Xext/panoramiXprocs.c21
-rw-r--r--xorg-server/Xext/saver.c2
-rw-r--r--xorg-server/Xext/shape.c2
-rw-r--r--xorg-server/Xext/shm.c10
-rw-r--r--xorg-server/Xext/sync.c4
-rw-r--r--xorg-server/Xext/xcmisc.c2
-rw-r--r--xorg-server/Xext/xf86bigfont.c4
-rw-r--r--xorg-server/Xext/xres.c2
-rw-r--r--xorg-server/Xext/xselinux_label.c2
-rwxr-xr-xxorg-server/Xext/xvmain.c2
12 files changed, 35 insertions, 30 deletions
diff --git a/xorg-server/Xext/hashtable.c b/xorg-server/Xext/hashtable.c
index f10ca769d..37505f97a 100644
--- a/xorg-server/Xext/hashtable.c
+++ b/xorg-server/Xext/hashtable.c
@@ -54,7 +54,7 @@ ht_create(int keySize,
ht->elements = 0;
ht->bucketBits = INITHASHSIZE;
numBuckets = 1 << ht->bucketBits;
- ht->buckets = malloc(numBuckets * sizeof(*ht->buckets));
+ ht->buckets = xallocarray(numBuckets, sizeof(*ht->buckets));
ht->cdata = cdata;
if (ht->buckets) {
@@ -92,7 +92,7 @@ double_size(HashTable ht)
int newNumBuckets = 1 << newBucketBits;
int c;
- newBuckets = malloc(newNumBuckets * sizeof(*ht->buckets));
+ newBuckets = xallocarray(newNumBuckets, sizeof(*ht->buckets));
if (newBuckets) {
for (c = 0; c < newNumBuckets; ++c) {
xorg_list_init(&newBuckets[c]);
diff --git a/xorg-server/Xext/panoramiX.c b/xorg-server/Xext/panoramiX.c
index 49b313df9..e59fbb733 100644
--- a/xorg-server/Xext/panoramiX.c
+++ b/xorg-server/Xext/panoramiX.c
@@ -747,13 +747,13 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth)
j = PanoramiXNumDepths;
PanoramiXNumDepths++;
- PanoramiXDepths = realloc(PanoramiXDepths,
- PanoramiXNumDepths * sizeof(DepthRec));
+ PanoramiXDepths = reallocarray(PanoramiXDepths,
+ PanoramiXNumDepths, sizeof(DepthRec));
PanoramiXDepths[j].depth = pDepth->depth;
PanoramiXDepths[j].numVids = 0;
/* XXX suboptimal, should grow these dynamically */
if (pDepth->numVids)
- PanoramiXDepths[j].vids = malloc(sizeof(VisualID) * pDepth->numVids);
+ PanoramiXDepths[j].vids = xallocarray(pDepth->numVids, sizeof(VisualID));
else
PanoramiXDepths[j].vids = NULL;
}
@@ -789,8 +789,8 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual)
/* found a matching visual on all screens, add it to the subset list */
j = PanoramiXNumVisuals;
PanoramiXNumVisuals++;
- PanoramiXVisuals = realloc(PanoramiXVisuals,
- PanoramiXNumVisuals * sizeof(VisualRec));
+ PanoramiXVisuals = reallocarray(PanoramiXVisuals,
+ PanoramiXNumVisuals, sizeof(VisualRec));
memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec));
diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c
index 277d2c040..60985371e 100644
--- a/xorg-server/Xext/panoramiXprocs.c
+++ b/xorg-server/Xext/panoramiXprocs.c
@@ -1104,7 +1104,7 @@ PanoramiXCopyArea(ClientPtr client)
}
pitch = PixmapBytePad(stuff->width, drawables[0]->depth);
- if (!(data = calloc(1, stuff->height * pitch)))
+ if (!(data = calloc(stuff->height, pitch)))
return BadAlloc;
XineramaGetImageData(drawables, srcx, srcy,
@@ -1339,7 +1339,7 @@ PanoramiXPolyPoint(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint > 0) {
- origPts = malloc(npoint * sizeof(xPoint));
+ origPts = xallocarray(npoint, sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) {
@@ -1404,7 +1404,7 @@ PanoramiXPolyLine(ClientPtr client)
isRoot = IS_ROOT_DRAWABLE(draw);
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 0) {
- origPts = malloc(npoint * sizeof(xPoint));
+ origPts = xallocarray(npoint, sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) {
@@ -1473,7 +1473,7 @@ PanoramiXPolySegment(ClientPtr client)
return BadLength;
nsegs >>= 3;
if (nsegs > 0) {
- origSegs = malloc(nsegs * sizeof(xSegment));
+ origSegs = xallocarray(nsegs, sizeof(xSegment));
memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment));
FOR_NSCREENS_FORWARD(j) {
@@ -1541,7 +1541,7 @@ PanoramiXPolyRectangle(ClientPtr client)
return BadLength;
nrects >>= 3;
if (nrects > 0) {
- origRecs = malloc(nrects * sizeof(xRectangle));
+ origRecs = xallocarray(nrects, sizeof(xRectangle));
memcpy((char *) origRecs, (char *) &stuff[1],
nrects * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) {
@@ -1608,7 +1608,7 @@ PanoramiXPolyArc(ClientPtr client)
return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
- origArcs = malloc(narcs * sizeof(xArc));
+ origArcs = xallocarray(narcs, sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) {
@@ -1670,7 +1670,7 @@ PanoramiXFillPoly(ClientPtr client)
count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (count > 0) {
- locPts = malloc(count * sizeof(DDXPointRec));
+ locPts = xallocarray(count, sizeof(DDXPointRec));
memcpy((char *) locPts, (char *) &stuff[1],
count * sizeof(DDXPointRec));
FOR_NSCREENS_FORWARD(j) {
@@ -1739,7 +1739,7 @@ PanoramiXPolyFillRectangle(ClientPtr client)
return BadLength;
things >>= 3;
if (things > 0) {
- origRects = malloc(things * sizeof(xRectangle));
+ origRects = xallocarray(things, sizeof(xRectangle));
memcpy((char *) origRects, (char *) &stuff[1],
things * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) {
@@ -1806,7 +1806,7 @@ PanoramiXPolyFillArc(ClientPtr client)
return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
- origArcs = malloc(narcs * sizeof(xArc));
+ origArcs = xallocarray(narcs, sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) {
@@ -1986,8 +1986,7 @@ PanoramiXGetImage(ClientPtr client)
if (linesPerBuf > h)
linesPerBuf = h;
}
- length = linesPerBuf * widthBytesLine;
- if (!(pBuf = malloc(length)))
+ if (!(pBuf = xallocarray(linesPerBuf, widthBytesLine)))
return BadAlloc;
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c
index 43c110dac..08dcb7824 100644
--- a/xorg-server/Xext/saver.c
+++ b/xorg-server/Xext/saver.c
@@ -856,7 +856,7 @@ ScreenSaverSetAttributes(ClientPtr client)
goto bail;
}
/* over allocate for override redirect */
- pAttr->values = values = malloc((len + 1) * sizeof(unsigned long));
+ pAttr->values = values = xallocarray(len + 1, sizeof(unsigned long));
if (!values) {
ret = BadAlloc;
goto bail;
diff --git a/xorg-server/Xext/shape.c b/xorg-server/Xext/shape.c
index c6ff360ac..48a327d5c 100644
--- a/xorg-server/Xext/shape.c
+++ b/xorg-server/Xext/shape.c
@@ -995,7 +995,7 @@ ProcShapeGetRectangles(ClientPtr client)
nrects = RegionNumRects(region);
box = RegionRects(region);
- rects = malloc(nrects * sizeof(xRectangle));
+ rects = xallocarray(nrects, sizeof(xRectangle));
if (!rects && nrects)
return BadAlloc;
for (i = 0; i < nrects; i++, box++) {
diff --git a/xorg-server/Xext/shm.c b/xorg-server/Xext/shm.c
index db278a3f4..7993d78d8 100644
--- a/xorg-server/Xext/shm.c
+++ b/xorg-server/Xext/shm.c
@@ -262,7 +262,7 @@ ShmDestroyPixmap(PixmapPtr pPixmap)
pScreen->DestroyPixmap = ShmDestroyPixmap;
if (shmdesc)
- ShmDetachSegment(shmdesc, pPixmap->drawable.id);
+ ShmDetachSegment(shmdesc, 0);
return ret;
}
@@ -444,7 +444,7 @@ ProcShmAttach(ClientPtr client)
/*ARGSUSED*/ static int
ShmDetachSegment(void *value, /* must conform to DeleteType */
- XID shmseg)
+ XID unused)
{
ShmDescPtr shmdesc = (ShmDescPtr) value;
ShmDescPtr *prev;
@@ -990,6 +990,12 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
stuff->offset);
if (pMap) {
+ result = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid,
+ RT_PIXMAP, pMap, RT_NONE, NULL, DixCreateAccess);
+ if (result != Success) {
+ pDraw->pScreen->DestroyPixmap(pMap);
+ return result;
+ }
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
diff --git a/xorg-server/Xext/sync.c b/xorg-server/Xext/sync.c
index 331473981..12ede5eac 100644
--- a/xorg-server/Xext/sync.c
+++ b/xorg-server/Xext/sync.c
@@ -618,7 +618,7 @@ SyncAwaitTriggerFired(SyncTrigger * pTrigger)
pAwaitUnion = (SyncAwaitUnion *) pAwait->pHeader;
numwaits = pAwaitUnion->header.num_waitconditions;
- ppAwait = malloc(numwaits * sizeof(SyncAwait *));
+ ppAwait = xallocarray(numwaits, sizeof(SyncAwait *));
if (!ppAwait)
goto bail;
@@ -1516,7 +1516,7 @@ SyncAwaitPrologue(ClientPtr client, int items)
/* all the memory for the entire await list is allocated
* here in one chunk
*/
- pAwaitUnion = malloc((items + 1) * sizeof(SyncAwaitUnion));
+ pAwaitUnion = xallocarray(items + 1, sizeof(SyncAwaitUnion));
if (!pAwaitUnion)
return NULL;
diff --git a/xorg-server/Xext/xcmisc.c b/xorg-server/Xext/xcmisc.c
index ddbae0d31..8d3c37be5 100644
--- a/xorg-server/Xext/xcmisc.c
+++ b/xorg-server/Xext/xcmisc.c
@@ -98,7 +98,7 @@ ProcXCMiscGetXIDList(ClientPtr client)
if (stuff->count > UINT32_MAX / sizeof(XID))
return BadAlloc;
- pids = (XID *) malloc(stuff->count * sizeof(XID));
+ pids = xallocarray(stuff->count, sizeof(XID));
if (!pids) {
return BadAlloc;
}
diff --git a/xorg-server/Xext/xf86bigfont.c b/xorg-server/Xext/xf86bigfont.c
index 5877a7174..a9a05ac62 100644
--- a/xorg-server/Xext/xf86bigfont.c
+++ b/xorg-server/Xext/xf86bigfont.c
@@ -406,7 +406,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
}
else {
#endif
- pCI = malloc(nCharInfos * sizeof(xCharInfo));
+ pCI = xallocarray(nCharInfos, sizeof(xCharInfo));
if (!pCI)
return BadAlloc;
#ifdef HAS_SHM
@@ -468,7 +468,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
if (hashModulus > nCharInfos + 1)
hashModulus = nCharInfos + 1;
- tmp = malloc((4 * nCharInfos + 1) * sizeof(CARD16));
+ tmp = xallocarray(4 * nCharInfos + 1, sizeof(CARD16));
if (!tmp) {
if (!pDesc)
free(pCI);
diff --git a/xorg-server/Xext/xres.c b/xorg-server/Xext/xres.c
index 191380490..4fe773108 100644
--- a/xorg-server/Xext/xres.c
+++ b/xorg-server/Xext/xres.c
@@ -222,7 +222,7 @@ ProcXResQueryClients(ClientPtr client)
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
- current_clients = malloc(currentMaxClients * sizeof(int));
+ current_clients = xallocarray(currentMaxClients, sizeof(int));
num_clients = 0;
for (i = 0; i < currentMaxClients; i++) {
diff --git a/xorg-server/Xext/xselinux_label.c b/xorg-server/Xext/xselinux_label.c
index 2c33d1cbf..8559385b9 100644
--- a/xorg-server/Xext/xselinux_label.c
+++ b/xorg-server/Xext/xselinux_label.c
@@ -64,7 +64,7 @@ SELinuxArraySet(SELinuxArrayRec * rec, unsigned key, void *val)
{
if (key >= rec->size) {
/* Need to increase size of array */
- rec->array = realloc(rec->array, (key + 1) * sizeof(val));
+ rec->array = reallocarray(rec->array, key + 1, sizeof(val));
if (!rec->array)
return FALSE;
memset(rec->array + rec->size, 0, (key - rec->size + 1) * sizeof(val));
diff --git a/xorg-server/Xext/xvmain.c b/xorg-server/Xext/xvmain.c
index 8e4c26c17..68ebcc9c4 100755
--- a/xorg-server/Xext/xvmain.c
+++ b/xorg-server/Xext/xvmain.c
@@ -1102,7 +1102,7 @@ XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
(void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
ValidateGC(pDraw, gc);
- rects = malloc(nbox * sizeof(xRectangle));
+ rects = xallocarray(nbox, sizeof(xRectangle));
if (rects) {
for (i = 0; i < nbox; i++, pbox++) {
rects[i].x = pbox->x1 - pDraw->x;