Lines 711-716
ProcPanoramiXShmCreatePixmap(
Link Here
|
711 |
int i, j, result, rc; |
711 |
int i, j, result, rc; |
712 |
ShmDescPtr shmdesc; |
712 |
ShmDescPtr shmdesc; |
713 |
REQUEST(xShmCreatePixmapReq); |
713 |
REQUEST(xShmCreatePixmapReq); |
|
|
714 |
unsigned int width, height, depth; |
715 |
unsigned long size; |
714 |
PanoramiXRes *newPix; |
716 |
PanoramiXRes *newPix; |
715 |
|
717 |
|
716 |
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); |
718 |
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); |
Lines 724-734
ProcPanoramiXShmCreatePixmap(
Link Here
|
724 |
return rc; |
726 |
return rc; |
725 |
|
727 |
|
726 |
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); |
728 |
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); |
727 |
if (!stuff->width || !stuff->height) |
729 |
|
|
|
730 |
width = stuff->width; |
731 |
height = stuff->height; |
732 |
depth = stuff->depth; |
733 |
if (!width || !height || !depth) |
728 |
{ |
734 |
{ |
729 |
client->errorValue = 0; |
735 |
client->errorValue = 0; |
730 |
return BadValue; |
736 |
return BadValue; |
731 |
} |
737 |
} |
|
|
738 |
if (width > 32767 || height > 32767) |
739 |
return BadAlloc; |
740 |
size = PixmapBytePad(width, depth) * height; |
741 |
if (sizeof(size) == 4) { |
742 |
if (size < width * height) |
743 |
return BadAlloc; |
744 |
/* thankfully, offset is unsigned */ |
745 |
if (stuff->offset + size < size) |
746 |
return BadAlloc; |
747 |
} |
748 |
|
732 |
if (stuff->depth != 1) |
749 |
if (stuff->depth != 1) |
733 |
{ |
750 |
{ |
734 |
pDepth = pDraw->pScreen->allowedDepths; |
751 |
pDepth = pDraw->pScreen->allowedDepths; |
Lines 739-747
ProcPanoramiXShmCreatePixmap(
Link Here
|
739 |
return BadValue; |
756 |
return BadValue; |
740 |
} |
757 |
} |
741 |
CreatePmap: |
758 |
CreatePmap: |
742 |
VERIFY_SHMSIZE(shmdesc, stuff->offset, |
759 |
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); |
743 |
PixmapBytePad(stuff->width, stuff->depth) * stuff->height, |
|
|
744 |
client); |
745 |
|
760 |
|
746 |
if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) |
761 |
if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) |
747 |
return BadAlloc; |
762 |
return BadAlloc; |
Lines 1040-1045
ProcShmCreatePixmap(client)
Link Here
|
1040 |
register int i, rc; |
1055 |
register int i, rc; |
1041 |
ShmDescPtr shmdesc; |
1056 |
ShmDescPtr shmdesc; |
1042 |
REQUEST(xShmCreatePixmapReq); |
1057 |
REQUEST(xShmCreatePixmapReq); |
|
|
1058 |
unsigned int width, height, depth; |
1059 |
unsigned long size; |
1043 |
|
1060 |
|
1044 |
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); |
1061 |
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); |
1045 |
client->errorValue = stuff->pid; |
1062 |
client->errorValue = stuff->pid; |
Lines 1052-1062
ProcShmCreatePixmap(client)
Link Here
|
1052 |
return rc; |
1069 |
return rc; |
1053 |
|
1070 |
|
1054 |
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); |
1071 |
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); |
1055 |
if (!stuff->width || !stuff->height) |
1072 |
|
|
|
1073 |
width = stuff->width; |
1074 |
height = stuff->height; |
1075 |
depth = stuff->depth; |
1076 |
if (!width || !height || !depth) |
1056 |
{ |
1077 |
{ |
1057 |
client->errorValue = 0; |
1078 |
client->errorValue = 0; |
1058 |
return BadValue; |
1079 |
return BadValue; |
1059 |
} |
1080 |
} |
|
|
1081 |
if (width > 32767 || height > 32767) |
1082 |
return BadAlloc; |
1083 |
size = PixmapBytePad(width, depth) * height; |
1084 |
if (sizeof(size) == 4) { |
1085 |
if (size < width * height) |
1086 |
return BadAlloc; |
1087 |
/* thankfully, offset is unsigned */ |
1088 |
if (stuff->offset + size < size) |
1089 |
return BadAlloc; |
1090 |
} |
1091 |
|
1060 |
if (stuff->depth != 1) |
1092 |
if (stuff->depth != 1) |
1061 |
{ |
1093 |
{ |
1062 |
pDepth = pDraw->pScreen->allowedDepths; |
1094 |
pDepth = pDraw->pScreen->allowedDepths; |
Lines 1067-1075
ProcShmCreatePixmap(client)
Link Here
|
1067 |
return BadValue; |
1099 |
return BadValue; |
1068 |
} |
1100 |
} |
1069 |
CreatePmap: |
1101 |
CreatePmap: |
1070 |
VERIFY_SHMSIZE(shmdesc, stuff->offset, |
1102 |
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); |
1071 |
PixmapBytePad(stuff->width, stuff->depth) * stuff->height, |
|
|
1072 |
client); |
1073 |
pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)( |
1103 |
pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)( |
1074 |
pDraw->pScreen, stuff->width, |
1104 |
pDraw->pScreen, stuff->width, |
1075 |
stuff->height, stuff->depth, |
1105 |
stuff->height, stuff->depth, |