Lines 723-728
ProcPanoramiXShmCreatePixmap(
Link Here
|
723 |
int i, j, result; |
723 |
int i, j, result; |
724 |
ShmDescPtr shmdesc; |
724 |
ShmDescPtr shmdesc; |
725 |
REQUEST(xShmCreatePixmapReq); |
725 |
REQUEST(xShmCreatePixmapReq); |
|
|
726 |
unsigned int width, height, depth; |
727 |
unsigned long size; |
726 |
PanoramiXRes *newPix; |
728 |
PanoramiXRes *newPix; |
727 |
|
729 |
|
728 |
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); |
730 |
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); |
Lines 732-742
ProcPanoramiXShmCreatePixmap(
Link Here
|
732 |
LEGAL_NEW_RESOURCE(stuff->pid, client); |
734 |
LEGAL_NEW_RESOURCE(stuff->pid, client); |
733 |
VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); |
735 |
VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); |
734 |
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); |
736 |
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); |
735 |
if (!stuff->width || !stuff->height) |
737 |
|
|
|
738 |
width = stuff->width; |
739 |
height = stuff->height; |
740 |
depth = stuff->depth; |
741 |
if (!width || !height || !depth) |
736 |
{ |
742 |
{ |
737 |
client->errorValue = 0; |
743 |
client->errorValue = 0; |
738 |
return BadValue; |
744 |
return BadValue; |
739 |
} |
745 |
} |
|
|
746 |
if (width > 32767 || height > 32767) |
747 |
return BadAlloc; |
748 |
size = PixmapBytePad(width, depth) * height; |
749 |
if (sizeof(size) == 4) { |
750 |
if (size < width * height) |
751 |
return BadAlloc; |
752 |
/* thankfully, offset is unsigned */ |
753 |
if (stuff->offset + size < size) |
754 |
return BadAlloc; |
755 |
} |
756 |
|
740 |
if (stuff->depth != 1) |
757 |
if (stuff->depth != 1) |
741 |
{ |
758 |
{ |
742 |
pDepth = pDraw->pScreen->allowedDepths; |
759 |
pDepth = pDraw->pScreen->allowedDepths; |
Lines 747-755
ProcPanoramiXShmCreatePixmap(
Link Here
|
747 |
return BadValue; |
764 |
return BadValue; |
748 |
} |
765 |
} |
749 |
CreatePmap: |
766 |
CreatePmap: |
750 |
VERIFY_SHMSIZE(shmdesc, stuff->offset, |
767 |
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); |
751 |
PixmapBytePad(stuff->width, stuff->depth) * stuff->height, |
|
|
752 |
client); |
753 |
|
768 |
|
754 |
if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) |
769 |
if(!(newPix = (PanoramiXRes *) xalloc(sizeof(PanoramiXRes)))) |
755 |
return BadAlloc; |
770 |
return BadAlloc; |
Lines 1047-1052
ProcShmCreatePixmap(client)
Link Here
|
1047 |
register int i; |
1062 |
register int i; |
1048 |
ShmDescPtr shmdesc; |
1063 |
ShmDescPtr shmdesc; |
1049 |
REQUEST(xShmCreatePixmapReq); |
1064 |
REQUEST(xShmCreatePixmapReq); |
|
|
1065 |
unsigned int width, height, depth; |
1066 |
unsigned long size; |
1050 |
|
1067 |
|
1051 |
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); |
1068 |
REQUEST_SIZE_MATCH(xShmCreatePixmapReq); |
1052 |
client->errorValue = stuff->pid; |
1069 |
client->errorValue = stuff->pid; |
Lines 1055-1065
ProcShmCreatePixmap(client)
Link Here
|
1055 |
LEGAL_NEW_RESOURCE(stuff->pid, client); |
1072 |
LEGAL_NEW_RESOURCE(stuff->pid, client); |
1056 |
VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); |
1073 |
VERIFY_GEOMETRABLE(pDraw, stuff->drawable, client); |
1057 |
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); |
1074 |
VERIFY_SHMPTR(stuff->shmseg, stuff->offset, TRUE, shmdesc, client); |
1058 |
if (!stuff->width || !stuff->height) |
1075 |
|
|
|
1076 |
width = stuff->width; |
1077 |
height = stuff->height; |
1078 |
depth = stuff->depth; |
1079 |
if (!width || !height || !depth) |
1059 |
{ |
1080 |
{ |
1060 |
client->errorValue = 0; |
1081 |
client->errorValue = 0; |
1061 |
return BadValue; |
1082 |
return BadValue; |
1062 |
} |
1083 |
} |
|
|
1084 |
if (width > 32767 || height > 32767) |
1085 |
return BadAlloc; |
1086 |
size = PixmapBytePad(width, depth) * height; |
1087 |
if (sizeof(size) == 4) { |
1088 |
if (size < width * height) |
1089 |
return BadAlloc; |
1090 |
/* thankfully, offset is unsigned */ |
1091 |
if (stuff->offset + size < size) |
1092 |
return BadAlloc; |
1093 |
} |
1094 |
|
1063 |
if (stuff->depth != 1) |
1095 |
if (stuff->depth != 1) |
1064 |
{ |
1096 |
{ |
1065 |
pDepth = pDraw->pScreen->allowedDepths; |
1097 |
pDepth = pDraw->pScreen->allowedDepths; |
Lines 1070-1078
ProcShmCreatePixmap(client)
Link Here
|
1070 |
return BadValue; |
1102 |
return BadValue; |
1071 |
} |
1103 |
} |
1072 |
CreatePmap: |
1104 |
CreatePmap: |
1073 |
VERIFY_SHMSIZE(shmdesc, stuff->offset, |
1105 |
VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); |
1074 |
PixmapBytePad(stuff->width, stuff->depth) * stuff->height, |
|
|
1075 |
client); |
1076 |
pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)( |
1106 |
pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)( |
1077 |
pDraw->pScreen, stuff->width, |
1107 |
pDraw->pScreen, stuff->width, |
1078 |
stuff->height, stuff->depth, |
1108 |
stuff->height, stuff->depth, |