idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
12,000
ProcChangeAccessControl(ClientPtr client) { REQUEST(xSetAccessControlReq); REQUEST_SIZE_MATCH(xSetAccessControlReq); if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess)) { client->errorValue = stuff->mode; return BadValue; } return ChangeAccessControl(client, stuff->mode == EnableAccess); }
DoS
0
ProcChangeAccessControl(ClientPtr client) { REQUEST(xSetAccessControlReq); REQUEST_SIZE_MATCH(xSetAccessControlReq); if ((stuff->mode != EnableAccess) && (stuff->mode != DisableAccess)) { client->errorValue = stuff->mode; return BadValue; } return ChangeAccessControl(client, stuff->mode == EnableAccess); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,001
ProcChangeCloseDownMode(ClientPtr client) { int rc; REQUEST(xSetCloseDownModeReq); REQUEST_SIZE_MATCH(xSetCloseDownModeReq); rc = XaceHook(XACE_CLIENT_ACCESS, client, client, DixManageAccess); if (rc != Success) return rc; if ((stuff->mode == AllTemporary) || (stuff->mode == RetainPermanent) || (stuff->mode == RetainTemporary)) { client->closeDownMode = stuff->mode; return Success; } else { client->errorValue = stuff->mode; return BadValue; } }
DoS
0
ProcChangeCloseDownMode(ClientPtr client) { int rc; REQUEST(xSetCloseDownModeReq); REQUEST_SIZE_MATCH(xSetCloseDownModeReq); rc = XaceHook(XACE_CLIENT_ACCESS, client, client, DixManageAccess); if (rc != Success) return rc; if ((stuff->mode == AllTemporary) || (stuff->mode == RetainPermanent) || (stuff->mode == RetainTemporary)) { client->closeDownMode = stuff->mode; return Success; } else { client->errorValue = stuff->mode; return BadValue; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,002
ProcChangeGC(ClientPtr client) { GC *pGC; int result; unsigned len; REQUEST(xChangeGCReq); REQUEST_AT_LEAST_SIZE(xChangeGCReq); result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess); if (result != Success) return result; len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq)); if (len != Ones(stuff->mask)) return BadLength; return ChangeGCXIDs(client, pGC, stuff->mask, (CARD32 *) &stuff[1]); }
DoS
0
ProcChangeGC(ClientPtr client) { GC *pGC; int result; unsigned len; REQUEST(xChangeGCReq); REQUEST_AT_LEAST_SIZE(xChangeGCReq); result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess); if (result != Success) return result; len = client->req_len - bytes_to_int32(sizeof(xChangeGCReq)); if (len != Ones(stuff->mask)) return BadLength; return ChangeGCXIDs(client, pGC, stuff->mask, (CARD32 *) &stuff[1]); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,003
ProcChangeHosts(ClientPtr client) { REQUEST(xChangeHostsReq); REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength); if (stuff->mode == HostInsert) return AddHost(client, (int) stuff->hostFamily, stuff->hostLength, (void *) &stuff[1]); if (stuff->mode == HostDelete) return RemoveHost(client, (int) stuff->hostFamily, stuff->hostLength, (void *) &stuff[1]); client->errorValue = stuff->mode; return BadValue; }
DoS
0
ProcChangeHosts(ClientPtr client) { REQUEST(xChangeHostsReq); REQUEST_FIXED_SIZE(xChangeHostsReq, stuff->hostLength); if (stuff->mode == HostInsert) return AddHost(client, (int) stuff->hostFamily, stuff->hostLength, (void *) &stuff[1]); if (stuff->mode == HostDelete) return RemoveHost(client, (int) stuff->hostFamily, stuff->hostLength, (void *) &stuff[1]); client->errorValue = stuff->mode; return BadValue; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,004
ProcChangeSaveSet(ClientPtr client) { WindowPtr pWin; REQUEST(xChangeSaveSetReq); int rc; REQUEST_SIZE_MATCH(xChangeSaveSetReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess); if (rc != Success) return rc; if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id))) return BadMatch; if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete)) return AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE); client->errorValue = stuff->mode; return BadValue; }
DoS
0
ProcChangeSaveSet(ClientPtr client) { WindowPtr pWin; REQUEST(xChangeSaveSetReq); int rc; REQUEST_SIZE_MATCH(xChangeSaveSetReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess); if (rc != Success) return rc; if (client->clientAsMask == (CLIENT_BITS(pWin->drawable.id))) return BadMatch; if ((stuff->mode == SetModeInsert) || (stuff->mode == SetModeDelete)) return AlterSaveSetForClient(client, pWin, stuff->mode, FALSE, TRUE); client->errorValue = stuff->mode; return BadValue; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,005
ProcChangeWindowAttributes(ClientPtr client) { WindowPtr pWin; REQUEST(xChangeWindowAttributesReq); int len, rc; Mask access_mode = 0; REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); access_mode |= (stuff->valueMask & CWEventMask) ? DixReceiveAccess : 0; access_mode |= (stuff->valueMask & ~CWEventMask) ? DixSetAttrAccess : 0; rc = dixLookupWindow(&pWin, stuff->window, client, access_mode); if (rc != Success) return rc; len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq)); if (len != Ones(stuff->valueMask)) return BadLength; return ChangeWindowAttributes(pWin, stuff->valueMask, (XID *) &stuff[1], client); }
DoS
0
ProcChangeWindowAttributes(ClientPtr client) { WindowPtr pWin; REQUEST(xChangeWindowAttributesReq); int len, rc; Mask access_mode = 0; REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq); access_mode |= (stuff->valueMask & CWEventMask) ? DixReceiveAccess : 0; access_mode |= (stuff->valueMask & ~CWEventMask) ? DixSetAttrAccess : 0; rc = dixLookupWindow(&pWin, stuff->window, client, access_mode); if (rc != Success) return rc; len = client->req_len - bytes_to_int32(sizeof(xChangeWindowAttributesReq)); if (len != Ones(stuff->valueMask)) return BadLength; return ChangeWindowAttributes(pWin, stuff->valueMask, (XID *) &stuff[1], client); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,006
ProcClearToBackground(ClientPtr client) { REQUEST(xClearAreaReq); WindowPtr pWin; int rc; REQUEST_SIZE_MATCH(xClearAreaReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); if (rc != Success) return rc; if (pWin->drawable.class == InputOnly) { client->errorValue = stuff->window; return BadMatch; } if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse)) { client->errorValue = stuff->exposures; return BadValue; } (*pWin->drawable.pScreen->ClearToBackground) (pWin, stuff->x, stuff->y, stuff->width, stuff->height, (Bool) stuff->exposures); return Success; }
DoS
0
ProcClearToBackground(ClientPtr client) { REQUEST(xClearAreaReq); WindowPtr pWin; int rc; REQUEST_SIZE_MATCH(xClearAreaReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixWriteAccess); if (rc != Success) return rc; if (pWin->drawable.class == InputOnly) { client->errorValue = stuff->window; return BadMatch; } if ((stuff->exposures != xTrue) && (stuff->exposures != xFalse)) { client->errorValue = stuff->exposures; return BadValue; } (*pWin->drawable.pScreen->ClearToBackground) (pWin, stuff->x, stuff->y, stuff->width, stuff->height, (Bool) stuff->exposures); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,007
ProcCloseFont(ClientPtr client) { FontPtr pFont; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pFont, stuff->id, RT_FONT, client, DixDestroyAccess); if (rc == Success) { FreeResource(stuff->id, RT_NONE); return Success; } else { client->errorValue = stuff->id; return rc; } }
DoS
0
ProcCloseFont(ClientPtr client) { FontPtr pFont; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pFont, stuff->id, RT_FONT, client, DixDestroyAccess); if (rc == Success) { FreeResource(stuff->id, RT_NONE); return Success; } else { client->errorValue = stuff->id; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,008
ProcConfigureWindow(ClientPtr client) { WindowPtr pWin; REQUEST(xConfigureWindowReq); int len, rc; REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess | DixSetAttrAccess); if (rc != Success) return rc; len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq)); if (Ones((Mask) stuff->mask) != len) return BadLength; return ConfigureWindow(pWin, (Mask) stuff->mask, (XID *) &stuff[1], client); }
DoS
0
ProcConfigureWindow(ClientPtr client) { WindowPtr pWin; REQUEST(xConfigureWindowReq); int len, rc; REQUEST_AT_LEAST_SIZE(xConfigureWindowReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess | DixSetAttrAccess); if (rc != Success) return rc; len = client->req_len - bytes_to_int32(sizeof(xConfigureWindowReq)); if (Ones((Mask) stuff->mask) != len) return BadLength; return ConfigureWindow(pWin, (Mask) stuff->mask, (XID *) &stuff[1], client); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,009
ProcCopyArea(ClientPtr client) { DrawablePtr pDst; DrawablePtr pSrc; GC *pGC; REQUEST(xCopyAreaReq); RegionPtr pRgn; int rc; REQUEST_SIZE_MATCH(xCopyAreaReq); VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess); if (stuff->dstDrawable != stuff->srcDrawable) { rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, DixReadAccess); if (rc != Success) return rc; if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { client->errorValue = stuff->dstDrawable; return BadMatch; } } else pSrc = pDst; pRgn = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, stuff->srcX, stuff->srcY, stuff->width, stuff->height, stuff->dstX, stuff->dstY); if (pGC->graphicsExposures) { SendGraphicsExpose(client, pRgn, stuff->dstDrawable, X_CopyArea, 0); if (pRgn) RegionDestroy(pRgn); } return Success; }
DoS
0
ProcCopyArea(ClientPtr client) { DrawablePtr pDst; DrawablePtr pSrc; GC *pGC; REQUEST(xCopyAreaReq); RegionPtr pRgn; int rc; REQUEST_SIZE_MATCH(xCopyAreaReq); VALIDATE_DRAWABLE_AND_GC(stuff->dstDrawable, pDst, DixWriteAccess); if (stuff->dstDrawable != stuff->srcDrawable) { rc = dixLookupDrawable(&pSrc, stuff->srcDrawable, client, 0, DixReadAccess); if (rc != Success) return rc; if ((pDst->pScreen != pSrc->pScreen) || (pDst->depth != pSrc->depth)) { client->errorValue = stuff->dstDrawable; return BadMatch; } } else pSrc = pDst; pRgn = (*pGC->ops->CopyArea) (pSrc, pDst, pGC, stuff->srcX, stuff->srcY, stuff->width, stuff->height, stuff->dstX, stuff->dstY); if (pGC->graphicsExposures) { SendGraphicsExpose(client, pRgn, stuff->dstDrawable, X_CopyArea, 0); if (pRgn) RegionDestroy(pRgn); } return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,010
ProcCopyColormapAndFree(ClientPtr client) { Colormap mid; ColormapPtr pSrcMap; REQUEST(xCopyColormapAndFreeReq); int rc; REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); rc = dixLookupResourceByType((void **) &pSrcMap, stuff->srcCmap, RT_COLORMAP, client, DixReadAccess | DixRemoveAccess); if (rc == Success) return CopyColormapAndFree(mid, pSrcMap, client->index); client->errorValue = stuff->srcCmap; return rc; }
DoS
0
ProcCopyColormapAndFree(ClientPtr client) { Colormap mid; ColormapPtr pSrcMap; REQUEST(xCopyColormapAndFreeReq); int rc; REQUEST_SIZE_MATCH(xCopyColormapAndFreeReq); mid = stuff->mid; LEGAL_NEW_RESOURCE(mid, client); rc = dixLookupResourceByType((void **) &pSrcMap, stuff->srcCmap, RT_COLORMAP, client, DixReadAccess | DixRemoveAccess); if (rc == Success) return CopyColormapAndFree(mid, pSrcMap, client->index); client->errorValue = stuff->srcCmap; return rc; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,011
ProcCopyGC(ClientPtr client) { GC *dstGC; GC *pGC; int result; REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); result = dixLookupGC(&pGC, stuff->srcGC, client, DixGetAttrAccess); if (result != Success) return result; result = dixLookupGC(&dstGC, stuff->dstGC, client, DixSetAttrAccess); if (result != Success) return result; if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) return BadMatch; if (stuff->mask & ~GCAllBits) { client->errorValue = stuff->mask; return BadValue; } return CopyGC(pGC, dstGC, stuff->mask); }
DoS
0
ProcCopyGC(ClientPtr client) { GC *dstGC; GC *pGC; int result; REQUEST(xCopyGCReq); REQUEST_SIZE_MATCH(xCopyGCReq); result = dixLookupGC(&pGC, stuff->srcGC, client, DixGetAttrAccess); if (result != Success) return result; result = dixLookupGC(&dstGC, stuff->dstGC, client, DixSetAttrAccess); if (result != Success) return result; if ((dstGC->pScreen != pGC->pScreen) || (dstGC->depth != pGC->depth)) return BadMatch; if (stuff->mask & ~GCAllBits) { client->errorValue = stuff->mask; return BadValue; } return CopyGC(pGC, dstGC, stuff->mask); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,012
ProcCreateCursor(ClientPtr client) { CursorPtr pCursor; PixmapPtr src; PixmapPtr msk; unsigned char *srcbits; unsigned char *mskbits; unsigned short width, height; long n; CursorMetricRec cm; int rc; REQUEST(xCreateCursorReq); REQUEST_SIZE_MATCH(xCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); rc = dixLookupResourceByType((void **) &src, stuff->source, RT_PIXMAP, client, DixReadAccess); if (rc != Success) { client->errorValue = stuff->source; return rc; } if (src->drawable.depth != 1) return (BadMatch); /* Find and validate cursor mask pixmap, if one is provided */ if (stuff->mask != None) { rc = dixLookupResourceByType((void **) &msk, stuff->mask, RT_PIXMAP, client, DixReadAccess); if (rc != Success) { client->errorValue = stuff->mask; return rc; } if (src->drawable.width != msk->drawable.width || src->drawable.height != msk->drawable.height || src->drawable.depth != 1 || msk->drawable.depth != 1) return BadMatch; } else msk = NULL; width = src->drawable.width; height = src->drawable.height; if (stuff->x > width || stuff->y > height) return BadMatch; n = BitmapBytePad(width) * height; srcbits = calloc(1, n); if (!srcbits) return BadAlloc; mskbits = malloc(n); if (!mskbits) { free(srcbits); return BadAlloc; } (*src->drawable.pScreen->GetImage) ((DrawablePtr) src, 0, 0, width, height, XYPixmap, 1, (void *) srcbits); if (msk == (PixmapPtr) NULL) { unsigned char *bits = mskbits; while (--n >= 0) *bits++ = ~0; } else { /* zeroing the (pad) bits helps some ddx cursor handling */ memset((char *) mskbits, 0, n); (*msk->drawable.pScreen->GetImage) ((DrawablePtr) msk, 0, 0, width, height, XYPixmap, 1, (void *) mskbits); } cm.width = width; cm.height = height; cm.xhot = stuff->x; cm.yhot = stuff->y; rc = AllocARGBCursor(srcbits, mskbits, NULL, &cm, stuff->foreRed, stuff->foreGreen, stuff->foreBlue, stuff->backRed, stuff->backGreen, stuff->backBlue, &pCursor, client, stuff->cid); if (rc != Success) goto bail; if (!AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) { rc = BadAlloc; goto bail; } return Success; bail: free(srcbits); free(mskbits); return rc; }
DoS
0
ProcCreateCursor(ClientPtr client) { CursorPtr pCursor; PixmapPtr src; PixmapPtr msk; unsigned char *srcbits; unsigned char *mskbits; unsigned short width, height; long n; CursorMetricRec cm; int rc; REQUEST(xCreateCursorReq); REQUEST_SIZE_MATCH(xCreateCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); rc = dixLookupResourceByType((void **) &src, stuff->source, RT_PIXMAP, client, DixReadAccess); if (rc != Success) { client->errorValue = stuff->source; return rc; } if (src->drawable.depth != 1) return (BadMatch); /* Find and validate cursor mask pixmap, if one is provided */ if (stuff->mask != None) { rc = dixLookupResourceByType((void **) &msk, stuff->mask, RT_PIXMAP, client, DixReadAccess); if (rc != Success) { client->errorValue = stuff->mask; return rc; } if (src->drawable.width != msk->drawable.width || src->drawable.height != msk->drawable.height || src->drawable.depth != 1 || msk->drawable.depth != 1) return BadMatch; } else msk = NULL; width = src->drawable.width; height = src->drawable.height; if (stuff->x > width || stuff->y > height) return BadMatch; n = BitmapBytePad(width) * height; srcbits = calloc(1, n); if (!srcbits) return BadAlloc; mskbits = malloc(n); if (!mskbits) { free(srcbits); return BadAlloc; } (*src->drawable.pScreen->GetImage) ((DrawablePtr) src, 0, 0, width, height, XYPixmap, 1, (void *) srcbits); if (msk == (PixmapPtr) NULL) { unsigned char *bits = mskbits; while (--n >= 0) *bits++ = ~0; } else { /* zeroing the (pad) bits helps some ddx cursor handling */ memset((char *) mskbits, 0, n); (*msk->drawable.pScreen->GetImage) ((DrawablePtr) msk, 0, 0, width, height, XYPixmap, 1, (void *) mskbits); } cm.width = width; cm.height = height; cm.xhot = stuff->x; cm.yhot = stuff->y; rc = AllocARGBCursor(srcbits, mskbits, NULL, &cm, stuff->foreRed, stuff->foreGreen, stuff->foreBlue, stuff->backRed, stuff->backGreen, stuff->backBlue, &pCursor, client, stuff->cid); if (rc != Success) goto bail; if (!AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) { rc = BadAlloc; goto bail; } return Success; bail: free(srcbits); free(mskbits); return rc; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,013
ProcCreateGC(ClientPtr client) { int error, rc; GC *pGC; DrawablePtr pDraw; unsigned len; REQUEST(xCreateGCReq); REQUEST_AT_LEAST_SIZE(xCreateGCReq); client->errorValue = stuff->gc; LEGAL_NEW_RESOURCE(stuff->gc, client); rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixGetAttrAccess); if (rc != Success) return rc; len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq)); if (len != Ones(stuff->mask)) return BadLength; pGC = (GC *) CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error, stuff->gc, client); if (error != Success) return error; if (!AddResource(stuff->gc, RT_GC, (void *) pGC)) return BadAlloc; return Success; }
DoS
0
ProcCreateGC(ClientPtr client) { int error, rc; GC *pGC; DrawablePtr pDraw; unsigned len; REQUEST(xCreateGCReq); REQUEST_AT_LEAST_SIZE(xCreateGCReq); client->errorValue = stuff->gc; LEGAL_NEW_RESOURCE(stuff->gc, client); rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixGetAttrAccess); if (rc != Success) return rc; len = client->req_len - bytes_to_int32(sizeof(xCreateGCReq)); if (len != Ones(stuff->mask)) return BadLength; pGC = (GC *) CreateGC(pDraw, stuff->mask, (XID *) &stuff[1], &error, stuff->gc, client); if (error != Success) return error; if (!AddResource(stuff->gc, RT_GC, (void *) pGC)) return BadAlloc; return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,014
ProcCreateGlyphCursor(ClientPtr client) { CursorPtr pCursor; int res; REQUEST(xCreateGlyphCursorReq); REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); res = AllocGlyphCursor(stuff->source, stuff->sourceChar, stuff->mask, stuff->maskChar, stuff->foreRed, stuff->foreGreen, stuff->foreBlue, stuff->backRed, stuff->backGreen, stuff->backBlue, &pCursor, client, stuff->cid); if (res != Success) return res; if (AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) return Success; return BadAlloc; }
DoS
0
ProcCreateGlyphCursor(ClientPtr client) { CursorPtr pCursor; int res; REQUEST(xCreateGlyphCursorReq); REQUEST_SIZE_MATCH(xCreateGlyphCursorReq); LEGAL_NEW_RESOURCE(stuff->cid, client); res = AllocGlyphCursor(stuff->source, stuff->sourceChar, stuff->mask, stuff->maskChar, stuff->foreRed, stuff->foreGreen, stuff->foreBlue, stuff->backRed, stuff->backGreen, stuff->backBlue, &pCursor, client, stuff->cid); if (res != Success) return res; if (AddResource(stuff->cid, RT_CURSOR, (void *) pCursor)) return Success; return BadAlloc; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,015
ProcCreatePixmap(ClientPtr client) { PixmapPtr pMap; DrawablePtr pDraw; REQUEST(xCreatePixmapReq); DepthPtr pDepth; int i, rc; REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; LEGAL_NEW_RESOURCE(stuff->pid, client); rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, DixGetAttrAccess); if (rc != Success) return rc; if (!stuff->width || !stuff->height) { client->errorValue = 0; return BadValue; } if (stuff->width > 32767 || stuff->height > 32767) { /* It is allowed to try and allocate a pixmap which is larger than * 32767 in either dimension. However, all of the framebuffer code * is buggy and does not reliably draw to such big pixmaps, basically * because the Region data structure operates with signed shorts * for the rectangles in it. * * Furthermore, several places in the X server computes the * size in bytes of the pixmap and tries to store it in an * integer. This integer can overflow and cause the allocated size * to be much smaller. * * So, such big pixmaps are rejected here with a BadAlloc */ return BadAlloc; } if (stuff->depth != 1) { pDepth = pDraw->pScreen->allowedDepths; for (i = 0; i < pDraw->pScreen->numDepths; i++, pDepth++) if (pDepth->depth == stuff->depth) goto CreatePmap; client->errorValue = stuff->depth; return BadValue; } CreatePmap: pMap = (PixmapPtr) (*pDraw->pScreen->CreatePixmap) (pDraw->pScreen, stuff->width, stuff->height, stuff->depth, 0); if (pMap) { pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = stuff->pid; /* security creation/labeling check */ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP, pMap, RT_NONE, NULL, DixCreateAccess); if (rc != Success) { (*pDraw->pScreen->DestroyPixmap) (pMap); return rc; } if (AddResource(stuff->pid, RT_PIXMAP, (void *) pMap)) return Success; } return BadAlloc; }
DoS
0
ProcCreatePixmap(ClientPtr client) { PixmapPtr pMap; DrawablePtr pDraw; REQUEST(xCreatePixmapReq); DepthPtr pDepth; int i, rc; REQUEST_SIZE_MATCH(xCreatePixmapReq); client->errorValue = stuff->pid; LEGAL_NEW_RESOURCE(stuff->pid, client); rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, DixGetAttrAccess); if (rc != Success) return rc; if (!stuff->width || !stuff->height) { client->errorValue = 0; return BadValue; } if (stuff->width > 32767 || stuff->height > 32767) { /* It is allowed to try and allocate a pixmap which is larger than * 32767 in either dimension. However, all of the framebuffer code * is buggy and does not reliably draw to such big pixmaps, basically * because the Region data structure operates with signed shorts * for the rectangles in it. * * Furthermore, several places in the X server computes the * size in bytes of the pixmap and tries to store it in an * integer. This integer can overflow and cause the allocated size * to be much smaller. * * So, such big pixmaps are rejected here with a BadAlloc */ return BadAlloc; } if (stuff->depth != 1) { pDepth = pDraw->pScreen->allowedDepths; for (i = 0; i < pDraw->pScreen->numDepths; i++, pDepth++) if (pDepth->depth == stuff->depth) goto CreatePmap; client->errorValue = stuff->depth; return BadValue; } CreatePmap: pMap = (PixmapPtr) (*pDraw->pScreen->CreatePixmap) (pDraw->pScreen, stuff->width, stuff->height, stuff->depth, 0); if (pMap) { pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = stuff->pid; /* security creation/labeling check */ rc = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid, RT_PIXMAP, pMap, RT_NONE, NULL, DixCreateAccess); if (rc != Success) { (*pDraw->pScreen->DestroyPixmap) (pMap); return rc; } if (AddResource(stuff->pid, RT_PIXMAP, (void *) pMap)) return Success; } return BadAlloc; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,016
ProcCreateWindow(ClientPtr client) { WindowPtr pParent, pWin; REQUEST(xCreateWindowReq); int len, rc; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); LEGAL_NEW_RESOURCE(stuff->wid, client); rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess); if (rc != Success) return rc; len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); if (Ones(stuff->mask) != len) return BadLength; if (!stuff->width || !stuff->height) { client->errorValue = 0; return BadValue; } pWin = CreateWindow(stuff->wid, pParent, stuff->x, stuff->y, stuff->width, stuff->height, stuff->borderWidth, stuff->class, stuff->mask, (XID *) &stuff[1], (int) stuff->depth, client, stuff->visual, &rc); if (pWin) { Mask mask = pWin->eventMask; pWin->eventMask = 0; /* subterfuge in case AddResource fails */ if (!AddResource(stuff->wid, RT_WINDOW, (void *) pWin)) return BadAlloc; pWin->eventMask = mask; } return rc; }
DoS
0
ProcCreateWindow(ClientPtr client) { WindowPtr pParent, pWin; REQUEST(xCreateWindowReq); int len, rc; REQUEST_AT_LEAST_SIZE(xCreateWindowReq); LEGAL_NEW_RESOURCE(stuff->wid, client); rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess); if (rc != Success) return rc; len = client->req_len - bytes_to_int32(sizeof(xCreateWindowReq)); if (Ones(stuff->mask) != len) return BadLength; if (!stuff->width || !stuff->height) { client->errorValue = 0; return BadValue; } pWin = CreateWindow(stuff->wid, pParent, stuff->x, stuff->y, stuff->width, stuff->height, stuff->borderWidth, stuff->class, stuff->mask, (XID *) &stuff[1], (int) stuff->depth, client, stuff->visual, &rc); if (pWin) { Mask mask = pWin->eventMask; pWin->eventMask = 0; /* subterfuge in case AddResource fails */ if (!AddResource(stuff->wid, RT_WINDOW, (void *) pWin)) return BadAlloc; pWin->eventMask = mask; } return rc; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,017
ProcDestroySubwindows(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixRemoveAccess); if (rc != Success) return rc; DestroySubwindows(pWin, client); return Success; }
DoS
0
ProcDestroySubwindows(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixRemoveAccess); if (rc != Success) return rc; DestroySubwindows(pWin, client); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,018
ProcDestroyWindow(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess); if (rc != Success) return rc; if (pWin->parent) { rc = dixLookupWindow(&pWin, pWin->parent->drawable.id, client, DixRemoveAccess); if (rc != Success) return rc; FreeResource(stuff->id, RT_NONE); } return Success; }
DoS
0
ProcDestroyWindow(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixDestroyAccess); if (rc != Success) return rc; if (pWin->parent) { rc = dixLookupWindow(&pWin, pWin->parent->drawable.id, client, DixRemoveAccess); if (rc != Success) return rc; FreeResource(stuff->id, RT_NONE); } return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,019
ProcEstablishConnection(ClientPtr client) { const char *reason; char *auth_proto, *auth_string; xConnClientPrefix *prefix; REQUEST(xReq); prefix = (xConnClientPrefix *) ((char *) stuff + sz_xReq); auth_proto = (char *) prefix + sz_xConnClientPrefix; auth_string = auth_proto + pad_to_int32(prefix->nbytesAuthProto); if ((prefix->majorVersion != X_PROTOCOL) || (prefix->minorVersion != X_PROTOCOL_REVISION)) reason = "Protocol version mismatch"; else reason = ClientAuthorized(client, (unsigned short) prefix->nbytesAuthProto, auth_proto, (unsigned short) prefix->nbytesAuthString, auth_string); return (SendConnSetup(client, reason)); }
DoS
0
ProcEstablishConnection(ClientPtr client) { const char *reason; char *auth_proto, *auth_string; xConnClientPrefix *prefix; REQUEST(xReq); prefix = (xConnClientPrefix *) ((char *) stuff + sz_xReq); auth_proto = (char *) prefix + sz_xConnClientPrefix; auth_string = auth_proto + pad_to_int32(prefix->nbytesAuthProto); if ((prefix->majorVersion != X_PROTOCOL) || (prefix->minorVersion != X_PROTOCOL_REVISION)) reason = "Protocol version mismatch"; else reason = ClientAuthorized(client, (unsigned short) prefix->nbytesAuthProto, auth_proto, (unsigned short) prefix->nbytesAuthString, auth_string); return (SendConnSetup(client, reason)); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,020
ProcFreeColormap(ClientPtr client) { ColormapPtr pmap; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pmap, stuff->id, RT_COLORMAP, client, DixDestroyAccess); if (rc == Success) { /* Freeing a default colormap is a no-op */ if (!(pmap->flags & IsDefault)) FreeResource(stuff->id, RT_NONE); return Success; } else { client->errorValue = stuff->id; return rc; } }
DoS
0
ProcFreeColormap(ClientPtr client) { ColormapPtr pmap; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pmap, stuff->id, RT_COLORMAP, client, DixDestroyAccess); if (rc == Success) { /* Freeing a default colormap is a no-op */ if (!(pmap->flags & IsDefault)) FreeResource(stuff->id, RT_NONE); return Success; } else { client->errorValue = stuff->id; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,021
ProcFreeColors(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xFreeColorsReq); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixRemoveAccess); if (rc == Success) { int count; if (pcmp->flags & AllAllocated) return BadAccess; count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq)); return FreeColors(pcmp, client->index, count, (Pixel *) &stuff[1], (Pixel) stuff->planeMask); } else { client->errorValue = stuff->cmap; return rc; } }
DoS
0
ProcFreeColors(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xFreeColorsReq); REQUEST_AT_LEAST_SIZE(xFreeColorsReq); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixRemoveAccess); if (rc == Success) { int count; if (pcmp->flags & AllAllocated) return BadAccess; count = bytes_to_int32((client->req_len << 2) - sizeof(xFreeColorsReq)); return FreeColors(pcmp, client->index, count, (Pixel *) &stuff[1], (Pixel) stuff->planeMask); } else { client->errorValue = stuff->cmap; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,022
ProcFreeCursor(ClientPtr client) { CursorPtr pCursor; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pCursor, stuff->id, RT_CURSOR, client, DixDestroyAccess); if (rc == Success) { FreeResource(stuff->id, RT_NONE); return Success; } else { client->errorValue = stuff->id; return rc; } }
DoS
0
ProcFreeCursor(ClientPtr client) { CursorPtr pCursor; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pCursor, stuff->id, RT_CURSOR, client, DixDestroyAccess); if (rc == Success) { FreeResource(stuff->id, RT_NONE); return Success; } else { client->errorValue = stuff->id; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,023
ProcFreeGC(ClientPtr client) { GC *pGC; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupGC(&pGC, stuff->id, client, DixDestroyAccess); if (rc != Success) return rc; FreeResource(stuff->id, RT_NONE); return Success; }
DoS
0
ProcFreeGC(ClientPtr client) { GC *pGC; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupGC(&pGC, stuff->id, client, DixDestroyAccess); if (rc != Success) return rc; FreeResource(stuff->id, RT_NONE); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,024
ProcFreePixmap(ClientPtr client) { PixmapPtr pMap; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pMap, stuff->id, RT_PIXMAP, client, DixDestroyAccess); if (rc == Success) { FreeResource(stuff->id, RT_NONE); return Success; } else { client->errorValue = stuff->id; return rc; } }
DoS
0
ProcFreePixmap(ClientPtr client) { PixmapPtr pMap; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pMap, stuff->id, RT_PIXMAP, client, DixDestroyAccess); if (rc == Success) { FreeResource(stuff->id, RT_NONE); return Success; } else { client->errorValue = stuff->id; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,025
ProcGetFontPath(ClientPtr client) { xGetFontPathReply reply; int rc, stringLens, numpaths; unsigned char *bufferStart; /* REQUEST (xReq); */ REQUEST_SIZE_MATCH(xReq); rc = GetFontPath(client, &numpaths, &stringLens, &bufferStart); if (rc != Success) return rc; reply = (xGetFontPathReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = bytes_to_int32(stringLens + numpaths), .nPaths = numpaths }; WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply); if (stringLens || numpaths) WriteToClient(client, stringLens + numpaths, bufferStart); return Success; }
DoS
0
ProcGetFontPath(ClientPtr client) { xGetFontPathReply reply; int rc, stringLens, numpaths; unsigned char *bufferStart; /* REQUEST (xReq); */ REQUEST_SIZE_MATCH(xReq); rc = GetFontPath(client, &numpaths, &stringLens, &bufferStart); if (rc != Success) return rc; reply = (xGetFontPathReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = bytes_to_int32(stringLens + numpaths), .nPaths = numpaths }; WriteReplyToClient(client, sizeof(xGetFontPathReply), &reply); if (stringLens || numpaths) WriteToClient(client, stringLens + numpaths, bufferStart); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,026
ProcGetGeometry(ClientPtr client) { xGetGeometryReply rep = { .type = X_Reply }; int status; if ((status = GetGeometry(client, &rep)) != Success) return status; WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); return Success; }
DoS
0
ProcGetGeometry(ClientPtr client) { xGetGeometryReply rep = { .type = X_Reply }; int status; if ((status = GetGeometry(client, &rep)) != Success) return status; WriteReplyToClient(client, sizeof(xGetGeometryReply), &rep); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,027
ProcGetScreenSaver(ClientPtr client) { xGetScreenSaverReply rep; int rc, i; REQUEST_SIZE_MATCH(xReq); for (i = 0; i < screenInfo.numScreens; i++) { rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], DixGetAttrAccess); if (rc != Success) return rc; } rep = (xGetScreenSaverReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, .timeout = ScreenSaverTime / MILLI_PER_SECOND, .interval = ScreenSaverInterval / MILLI_PER_SECOND, .preferBlanking = ScreenSaverBlanking, .allowExposures = ScreenSaverAllowExposures }; WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep); return Success; }
DoS
0
ProcGetScreenSaver(ClientPtr client) { xGetScreenSaverReply rep; int rc, i; REQUEST_SIZE_MATCH(xReq); for (i = 0; i < screenInfo.numScreens; i++) { rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], DixGetAttrAccess); if (rc != Success) return rc; } rep = (xGetScreenSaverReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, .timeout = ScreenSaverTime / MILLI_PER_SECOND, .interval = ScreenSaverInterval / MILLI_PER_SECOND, .preferBlanking = ScreenSaverBlanking, .allowExposures = ScreenSaverAllowExposures }; WriteReplyToClient(client, sizeof(xGetScreenSaverReply), &rep); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,028
ProcGetWindowAttributes(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); xGetWindowAttributesReply wa; int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess); if (rc != Success) return rc; memset(&wa, 0, sizeof(xGetWindowAttributesReply)); GetWindowAttributes(pWin, client, &wa); WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa); return Success; }
DoS
0
ProcGetWindowAttributes(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); xGetWindowAttributesReply wa; int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess); if (rc != Success) return rc; memset(&wa, 0, sizeof(xGetWindowAttributesReply)); GetWindowAttributes(pWin, client, &wa); WriteReplyToClient(client, sizeof(xGetWindowAttributesReply), &wa); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,029
ProcGrabServer(ClientPtr client) { int rc; REQUEST_SIZE_MATCH(xReq); if (grabState != GrabNone && client != grabClient) { ResetCurrentRequest(client); client->sequence--; BITSET(grabWaiters, client->index); IgnoreClient(client); return Success; } rc = OnlyListenToOneClient(client); if (rc != Success) return rc; grabState = GrabKickout; grabClient = client; if (ServerGrabCallback) { ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_GRABBED; CallCallbacks(&ServerGrabCallback, (void *) &grabinfo); } return Success; }
DoS
0
ProcGrabServer(ClientPtr client) { int rc; REQUEST_SIZE_MATCH(xReq); if (grabState != GrabNone && client != grabClient) { ResetCurrentRequest(client); client->sequence--; BITSET(grabWaiters, client->index); IgnoreClient(client); return Success; } rc = OnlyListenToOneClient(client); if (rc != Success) return rc; grabState = GrabKickout; grabClient = client; if (ServerGrabCallback) { ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_GRABBED; CallCallbacks(&ServerGrabCallback, (void *) &grabinfo); } return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,030
ProcImageText16(ClientPtr client) { int err; DrawablePtr pDraw; GC *pGC; REQUEST(xImageTextReq); REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); err = ImageText(client, pDraw, pGC, stuff->nChars, (unsigned char *) &stuff[1], stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return Success; } else return err; }
DoS
0
ProcImageText16(ClientPtr client) { int err; DrawablePtr pDraw; GC *pGC; REQUEST(xImageTextReq); REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars << 1); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); err = ImageText(client, pDraw, pGC, stuff->nChars, (unsigned char *) &stuff[1], stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return Success; } else return err; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,031
ProcImageText8(ClientPtr client) { int err; DrawablePtr pDraw; GC *pGC; REQUEST(xImageTextReq); REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); err = ImageText(client, pDraw, pGC, stuff->nChars, (unsigned char *) &stuff[1], stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return Success; } else return err; }
DoS
0
ProcImageText8(ClientPtr client) { int err; DrawablePtr pDraw; GC *pGC; REQUEST(xImageTextReq); REQUEST_FIXED_SIZE(xImageTextReq, stuff->nChars); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); err = ImageText(client, pDraw, pGC, stuff->nChars, (unsigned char *) &stuff[1], stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return Success; } else return err; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,032
ProcInitialConnection(ClientPtr client) { REQUEST(xReq); xConnClientPrefix *prefix; int whichbyte = 1; char order; prefix = (xConnClientPrefix *) ((char *)stuff + sz_xReq); order = prefix->byteOrder; if (order != 'l' && order != 'B' && order != 'r' && order != 'R') return client->noClientException = -1; if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) || (!(*(char *) &whichbyte) && (order == 'l' || order == 'r'))) { client->swapped = TRUE; SwapConnClientPrefix(prefix); } stuff->reqType = 2; stuff->length += bytes_to_int32(prefix->nbytesAuthProto) + bytes_to_int32(prefix->nbytesAuthString); if (client->swapped) { swaps(&stuff->length); } if (order == 'r' || order == 'R') { client->local = FALSE; } ResetCurrentRequest(client); return Success; }
DoS
0
ProcInitialConnection(ClientPtr client) { REQUEST(xReq); xConnClientPrefix *prefix; int whichbyte = 1; char order; prefix = (xConnClientPrefix *) ((char *)stuff + sz_xReq); order = prefix->byteOrder; if (order != 'l' && order != 'B' && order != 'r' && order != 'R') return client->noClientException = -1; if (((*(char *) &whichbyte) && (order == 'B' || order == 'R')) || (!(*(char *) &whichbyte) && (order == 'l' || order == 'r'))) { client->swapped = TRUE; SwapConnClientPrefix(prefix); } stuff->reqType = 2; stuff->length += bytes_to_int32(prefix->nbytesAuthProto) + bytes_to_int32(prefix->nbytesAuthString); if (client->swapped) { swaps(&stuff->length); } if (order == 'r' || order == 'R') { client->local = FALSE; } ResetCurrentRequest(client); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,033
ProcInstallColormap(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pcmp, stuff->id, RT_COLORMAP, client, DixInstallAccess); if (rc != Success) goto out; rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess); if (rc != Success) { if (rc == BadValue) rc = BadColor; goto out; } (*(pcmp->pScreen->InstallColormap)) (pcmp); return Success; out: client->errorValue = stuff->id; return rc; }
DoS
0
ProcInstallColormap(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupResourceByType((void **) &pcmp, stuff->id, RT_COLORMAP, client, DixInstallAccess); if (rc != Success) goto out; rc = XaceHook(XACE_SCREEN_ACCESS, client, pcmp->pScreen, DixSetAttrAccess); if (rc != Success) { if (rc == BadValue) rc = BadColor; goto out; } (*(pcmp->pScreen->InstallColormap)) (pcmp); return Success; out: client->errorValue = stuff->id; return rc; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,034
ProcListFontsWithInfo(ClientPtr client) { REQUEST(xListFontsWithInfoReq); REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes); return StartListFontsWithInfo(client, stuff->nbytes, (unsigned char *) &stuff[1], stuff->maxNames); }
DoS
0
ProcListFontsWithInfo(ClientPtr client) { REQUEST(xListFontsWithInfoReq); REQUEST_FIXED_SIZE(xListFontsWithInfoReq, stuff->nbytes); return StartListFontsWithInfo(client, stuff->nbytes, (unsigned char *) &stuff[1], stuff->maxNames); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,035
ProcListInstalledColormaps(ClientPtr client) { xListInstalledColormapsReply *preply; int nummaps, rc; WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess); if (rc != Success) return rc; rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, DixGetAttrAccess); if (rc != Success) return rc; preply = malloc(sizeof(xListInstalledColormapsReply) + pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap)); if (!preply) return BadAlloc; preply->type = X_Reply; preply->sequenceNumber = client->sequence; nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps) (pWin->drawable.pScreen, (Colormap *) &preply[1]); preply->nColormaps = nummaps; preply->length = nummaps; WriteReplyToClient(client, sizeof(xListInstalledColormapsReply), preply); client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]); free(preply); return Success; }
DoS
0
ProcListInstalledColormaps(ClientPtr client) { xListInstalledColormapsReply *preply; int nummaps, rc; WindowPtr pWin; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixGetAttrAccess); if (rc != Success) return rc; rc = XaceHook(XACE_SCREEN_ACCESS, client, pWin->drawable.pScreen, DixGetAttrAccess); if (rc != Success) return rc; preply = malloc(sizeof(xListInstalledColormapsReply) + pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap)); if (!preply) return BadAlloc; preply->type = X_Reply; preply->sequenceNumber = client->sequence; nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps) (pWin->drawable.pScreen, (Colormap *) &preply[1]); preply->nColormaps = nummaps; preply->length = nummaps; WriteReplyToClient(client, sizeof(xListInstalledColormapsReply), preply); client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, nummaps * sizeof(Colormap), &preply[1]); free(preply); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,036
ProcLookupColor(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xLookupColorReq); REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixReadAccess); if (rc == Success) { CARD16 exactRed, exactGreen, exactBlue; if (OsLookupColor (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes, &exactRed, &exactGreen, &exactBlue)) { xLookupColorReply lcr = { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, .exactRed = exactRed, .exactGreen = exactGreen, .exactBlue = exactBlue, .screenRed = exactRed, .screenGreen = exactGreen, .screenBlue = exactBlue }; (*pcmp->pScreen->ResolveColor) (&lcr.screenRed, &lcr.screenGreen, &lcr.screenBlue, pcmp->pVisual); WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr); return Success; } return BadName; } else { client->errorValue = stuff->cmap; return rc; } }
DoS
0
ProcLookupColor(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xLookupColorReq); REQUEST_FIXED_SIZE(xLookupColorReq, stuff->nbytes); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixReadAccess); if (rc == Success) { CARD16 exactRed, exactGreen, exactBlue; if (OsLookupColor (pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes, &exactRed, &exactGreen, &exactBlue)) { xLookupColorReply lcr = { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, .exactRed = exactRed, .exactGreen = exactGreen, .exactBlue = exactBlue, .screenRed = exactRed, .screenGreen = exactGreen, .screenBlue = exactBlue }; (*pcmp->pScreen->ResolveColor) (&lcr.screenRed, &lcr.screenGreen, &lcr.screenBlue, pcmp->pVisual); WriteReplyToClient(client, sizeof(xLookupColorReply), &lcr); return Success; } return BadName; } else { client->errorValue = stuff->cmap; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,037
ProcMapWindow(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixShowAccess); if (rc != Success) return rc; MapWindow(pWin, client); /* update cache to say it is mapped */ return Success; }
DoS
0
ProcMapWindow(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixShowAccess); if (rc != Success) return rc; MapWindow(pWin, client); /* update cache to say it is mapped */ return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,038
ProcNoOperation(ClientPtr client) { REQUEST_AT_LEAST_SIZE(xReq); /* noop -- don't do anything */ return Success; }
DoS
0
ProcNoOperation(ClientPtr client) { REQUEST_AT_LEAST_SIZE(xReq); /* noop -- don't do anything */ return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,039
ProcOpenFont(ClientPtr client) { int err; REQUEST(xOpenFontReq); REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes); client->errorValue = stuff->fid; LEGAL_NEW_RESOURCE(stuff->fid, client); err = OpenFont(client, stuff->fid, (Mask) 0, stuff->nbytes, (char *) &stuff[1]); if (err == Success) { return Success; } else return err; }
DoS
0
ProcOpenFont(ClientPtr client) { int err; REQUEST(xOpenFontReq); REQUEST_FIXED_SIZE(xOpenFontReq, stuff->nbytes); client->errorValue = stuff->fid; LEGAL_NEW_RESOURCE(stuff->fid, client); err = OpenFont(client, stuff->fid, (Mask) 0, stuff->nbytes, (char *) &stuff[1]); if (err == Success) { return Success; } else return err; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,040
ProcPolyFillArc(ClientPtr client) { int narcs; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyFillArcReq); REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); if (narcs % sizeof(xArc)) return BadLength; narcs /= sizeof(xArc); if (narcs) (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]); return Success; }
DoS
0
ProcPolyFillArc(ClientPtr client) { int narcs; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyFillArcReq); REQUEST_AT_LEAST_SIZE(xPolyFillArcReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); narcs = (client->req_len << 2) - sizeof(xPolyFillArcReq); if (narcs % sizeof(xArc)) return BadLength; narcs /= sizeof(xArc); if (narcs) (*pGC->ops->PolyFillArc) (pDraw, pGC, narcs, (xArc *) &stuff[1]); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,041
ProcPolyFillRectangle(ClientPtr client) { int things; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyFillRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq); if (things & 4) return BadLength; things >>= 3; if (things) (*pGC->ops->PolyFillRect) (pDraw, pGC, things, (xRectangle *) &stuff[1]); return Success; }
DoS
0
ProcPolyFillRectangle(ClientPtr client) { int things; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyFillRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyFillRectangleReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); things = (client->req_len << 2) - sizeof(xPolyFillRectangleReq); if (things & 4) return BadLength; things >>= 3; if (things) (*pGC->ops->PolyFillRect) (pDraw, pGC, things, (xRectangle *) &stuff[1]); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,042
ProcPolyLine(ClientPtr client) { int npoint; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyLineReq); REQUEST_AT_LEAST_SIZE(xPolyLineReq); if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; return BadValue; } VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); if (npoint > 1) (*pGC->ops->Polylines) (pDraw, pGC, stuff->coordMode, npoint, (DDXPointPtr) &stuff[1]); return Success; }
DoS
0
ProcPolyLine(ClientPtr client) { int npoint; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyLineReq); REQUEST_AT_LEAST_SIZE(xPolyLineReq); if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; return BadValue; } VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq)); if (npoint > 1) (*pGC->ops->Polylines) (pDraw, pGC, stuff->coordMode, npoint, (DDXPointPtr) &stuff[1]); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,043
ProcPolyPoint(ClientPtr client) { int npoint; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyPointReq); REQUEST_AT_LEAST_SIZE(xPolyPointReq); if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; return BadValue; } VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); if (npoint) (*pGC->ops->PolyPoint) (pDraw, pGC, stuff->coordMode, npoint, (xPoint *) &stuff[1]); return Success; }
DoS
0
ProcPolyPoint(ClientPtr client) { int npoint; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyPointReq); REQUEST_AT_LEAST_SIZE(xPolyPointReq); if ((stuff->coordMode != CoordModeOrigin) && (stuff->coordMode != CoordModePrevious)) { client->errorValue = stuff->coordMode; return BadValue; } VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq)); if (npoint) (*pGC->ops->PolyPoint) (pDraw, pGC, stuff->coordMode, npoint, (xPoint *) &stuff[1]); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,044
ProcPolyRectangle(ClientPtr client) { int nrects; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq); if (nrects & 4) return BadLength; nrects >>= 3; if (nrects) (*pGC->ops->PolyRectangle) (pDraw, pGC, nrects, (xRectangle *) &stuff[1]); return Success; }
DoS
0
ProcPolyRectangle(ClientPtr client) { int nrects; GC *pGC; DrawablePtr pDraw; REQUEST(xPolyRectangleReq); REQUEST_AT_LEAST_SIZE(xPolyRectangleReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); nrects = (client->req_len << 2) - sizeof(xPolyRectangleReq); if (nrects & 4) return BadLength; nrects >>= 3; if (nrects) (*pGC->ops->PolyRectangle) (pDraw, pGC, nrects, (xRectangle *) &stuff[1]); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,045
ProcPolySegment(ClientPtr client) { int nsegs; GC *pGC; DrawablePtr pDraw; REQUEST(xPolySegmentReq); REQUEST_AT_LEAST_SIZE(xPolySegmentReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq); if (nsegs & 4) return BadLength; nsegs >>= 3; if (nsegs) (*pGC->ops->PolySegment) (pDraw, pGC, nsegs, (xSegment *) &stuff[1]); return Success; }
DoS
0
ProcPolySegment(ClientPtr client) { int nsegs; GC *pGC; DrawablePtr pDraw; REQUEST(xPolySegmentReq); REQUEST_AT_LEAST_SIZE(xPolySegmentReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); nsegs = (client->req_len << 2) - sizeof(xPolySegmentReq); if (nsegs & 4) return BadLength; nsegs >>= 3; if (nsegs) (*pGC->ops->PolySegment) (pDraw, pGC, nsegs, (xSegment *) &stuff[1]); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,046
ProcPolyText(ClientPtr client) { int err; REQUEST(xPolyTextReq); DrawablePtr pDraw; GC *pGC; REQUEST_AT_LEAST_SIZE(xPolyTextReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); err = PolyText(client, pDraw, pGC, (unsigned char *) &stuff[1], ((unsigned char *) stuff) + (client->req_len << 2), stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return Success; } else return err; }
DoS
0
ProcPolyText(ClientPtr client) { int err; REQUEST(xPolyTextReq); DrawablePtr pDraw; GC *pGC; REQUEST_AT_LEAST_SIZE(xPolyTextReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, DixWriteAccess); err = PolyText(client, pDraw, pGC, (unsigned char *) &stuff[1], ((unsigned char *) stuff) + (client->req_len << 2), stuff->x, stuff->y, stuff->reqType, stuff->drawable); if (err == Success) { return Success; } else return err; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,047
ProcQueryBestSize(ClientPtr client) { xQueryBestSizeReply reply; DrawablePtr pDraw; ScreenPtr pScreen; int rc; REQUEST(xQueryBestSizeReq); REQUEST_SIZE_MATCH(xQueryBestSizeReq); if ((stuff->class != CursorShape) && (stuff->class != TileShape) && (stuff->class != StippleShape)) { client->errorValue = stuff->class; return BadValue; } rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, DixGetAttrAccess); if (rc != Success) return rc; if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW) return BadMatch; pScreen = pDraw->pScreen; rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess); if (rc != Success) return rc; (*pScreen->QueryBestSize) (stuff->class, &stuff->width, &stuff->height, pScreen); reply = (xQueryBestSizeReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, .width = stuff->width, .height = stuff->height }; WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply); return Success; }
DoS
0
ProcQueryBestSize(ClientPtr client) { xQueryBestSizeReply reply; DrawablePtr pDraw; ScreenPtr pScreen; int rc; REQUEST(xQueryBestSizeReq); REQUEST_SIZE_MATCH(xQueryBestSizeReq); if ((stuff->class != CursorShape) && (stuff->class != TileShape) && (stuff->class != StippleShape)) { client->errorValue = stuff->class; return BadValue; } rc = dixLookupDrawable(&pDraw, stuff->drawable, client, M_ANY, DixGetAttrAccess); if (rc != Success) return rc; if (stuff->class != CursorShape && pDraw->type == UNDRAWABLE_WINDOW) return BadMatch; pScreen = pDraw->pScreen; rc = XaceHook(XACE_SCREEN_ACCESS, client, pScreen, DixGetAttrAccess); if (rc != Success) return rc; (*pScreen->QueryBestSize) (stuff->class, &stuff->width, &stuff->height, pScreen); reply = (xQueryBestSizeReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0, .width = stuff->width, .height = stuff->height }; WriteReplyToClient(client, sizeof(xQueryBestSizeReply), &reply); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,048
ProcQueryColors(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xQueryColorsReq); REQUEST_AT_LEAST_SIZE(xQueryColorsReq); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixReadAccess); if (rc == Success) { int count; xrgb *prgbs; xQueryColorsReply qcr; count = bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq)); prgbs = calloc(1, count * sizeof(xrgb)); if (!prgbs && count) return BadAlloc; if ((rc = QueryColors(pcmp, count, (Pixel *) &stuff[1], prgbs, client))) { free(prgbs); return rc; } qcr = (xQueryColorsReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = bytes_to_int32(count * sizeof(xrgb)), .nColors = count }; WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr); if (count) { client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend; WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs); } free(prgbs); return Success; } else { client->errorValue = stuff->cmap; return rc; } }
DoS
0
ProcQueryColors(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xQueryColorsReq); REQUEST_AT_LEAST_SIZE(xQueryColorsReq); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixReadAccess); if (rc == Success) { int count; xrgb *prgbs; xQueryColorsReply qcr; count = bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq)); prgbs = calloc(1, count * sizeof(xrgb)); if (!prgbs && count) return BadAlloc; if ((rc = QueryColors(pcmp, count, (Pixel *) &stuff[1], prgbs, client))) { free(prgbs); return rc; } qcr = (xQueryColorsReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = bytes_to_int32(count * sizeof(xrgb)), .nColors = count }; WriteReplyToClient(client, sizeof(xQueryColorsReply), &qcr); if (count) { client->pSwapReplyFunc = (ReplySwapPtr) SQColorsExtend; WriteSwappedDataToClient(client, count * sizeof(xrgb), prgbs); } free(prgbs); return Success; } else { client->errorValue = stuff->cmap; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,049
ProcQueryFont(ClientPtr client) { xQueryFontReply *reply; FontPtr pFont; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess); if (rc != Success) return rc; { xCharInfo *pmax = FONTINKMAX(pFont); xCharInfo *pmin = FONTINKMIN(pFont); int nprotoxcistructs; int rlength; nprotoxcistructs = (pmax->rightSideBearing == pmin->rightSideBearing && pmax->leftSideBearing == pmin->leftSideBearing && pmax->descent == pmin->descent && pmax->ascent == pmin->ascent && pmax->characterWidth == pmin->characterWidth) ? 0 : N2dChars(pFont); rlength = sizeof(xQueryFontReply) + FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) + nprotoxcistructs * sizeof(xCharInfo); reply = calloc(1, rlength); if (!reply) { return BadAlloc; } reply->type = X_Reply; reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); reply->sequenceNumber = client->sequence; QueryFont(pFont, reply, nprotoxcistructs); WriteReplyToClient(client, rlength, reply); free(reply); return Success; } }
DoS
0
ProcQueryFont(ClientPtr client) { xQueryFontReply *reply; FontPtr pFont; int rc; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess); if (rc != Success) return rc; { xCharInfo *pmax = FONTINKMAX(pFont); xCharInfo *pmin = FONTINKMIN(pFont); int nprotoxcistructs; int rlength; nprotoxcistructs = (pmax->rightSideBearing == pmin->rightSideBearing && pmax->leftSideBearing == pmin->leftSideBearing && pmax->descent == pmin->descent && pmax->ascent == pmin->ascent && pmax->characterWidth == pmin->characterWidth) ? 0 : N2dChars(pFont); rlength = sizeof(xQueryFontReply) + FONTINFONPROPS(FONTCHARSET(pFont)) * sizeof(xFontProp) + nprotoxcistructs * sizeof(xCharInfo); reply = calloc(1, rlength); if (!reply) { return BadAlloc; } reply->type = X_Reply; reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); reply->sequenceNumber = client->sequence; QueryFont(pFont, reply, nprotoxcistructs); WriteReplyToClient(client, rlength, reply); free(reply); return Success; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,050
ProcQueryTextExtents(ClientPtr client) { xQueryTextExtentsReply reply; FontPtr pFont; ExtentInfoRec info; unsigned long length; int rc; REQUEST(xQueryTextExtentsReq); REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); rc = dixLookupFontable(&pFont, stuff->fid, client, DixGetAttrAccess); if (rc != Success) return rc; length = client->req_len - bytes_to_int32(sizeof(xQueryTextExtentsReq)); length = length << 1; if (stuff->oddLength) { if (length == 0) return BadLength; length--; } if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info)) return BadAlloc; reply = (xQueryTextExtentsReply) { .type = X_Reply, .drawDirection = info.drawDirection, .sequenceNumber = client->sequence, .length = 0, .fontAscent = info.fontAscent, .fontDescent = info.fontDescent, .overallAscent = info.overallAscent, .overallDescent = info.overallDescent, .overallWidth = info.overallWidth, .overallLeft = info.overallLeft, .overallRight = info.overallRight }; WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply); return Success; }
DoS
0
ProcQueryTextExtents(ClientPtr client) { xQueryTextExtentsReply reply; FontPtr pFont; ExtentInfoRec info; unsigned long length; int rc; REQUEST(xQueryTextExtentsReq); REQUEST_AT_LEAST_SIZE(xQueryTextExtentsReq); rc = dixLookupFontable(&pFont, stuff->fid, client, DixGetAttrAccess); if (rc != Success) return rc; length = client->req_len - bytes_to_int32(sizeof(xQueryTextExtentsReq)); length = length << 1; if (stuff->oddLength) { if (length == 0) return BadLength; length--; } if (!QueryTextExtents(pFont, length, (unsigned char *) &stuff[1], &info)) return BadAlloc; reply = (xQueryTextExtentsReply) { .type = X_Reply, .drawDirection = info.drawDirection, .sequenceNumber = client->sequence, .length = 0, .fontAscent = info.fontAscent, .fontDescent = info.fontDescent, .overallAscent = info.overallAscent, .overallDescent = info.overallDescent, .overallWidth = info.overallWidth, .overallLeft = info.overallLeft, .overallRight = info.overallRight }; WriteReplyToClient(client, sizeof(xQueryTextExtentsReply), &reply); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,051
ProcQueryTree(ClientPtr client) { xQueryTreeReply reply; int rc, numChildren = 0; WindowPtr pChild, pWin, pHead; Window *childIDs = (Window *) NULL; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess); if (rc != Success) return rc; reply = (xQueryTreeReply) { .type = X_Reply, .sequenceNumber = client->sequence, .root = pWin->drawable.pScreen->root->drawable.id, .parent = (pWin->parent) ? pWin->parent->drawable.id : (Window) None }; pHead = RealChildHead(pWin); for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) numChildren++; if (numChildren) { int curChild = 0; childIDs = malloc(numChildren * sizeof(Window)); if (!childIDs) return BadAlloc; for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) childIDs[curChild++] = pChild->drawable.id; } reply.nChildren = numChildren; reply.length = bytes_to_int32(numChildren * sizeof(Window)); WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); if (numChildren) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); free(childIDs); } return Success; }
DoS
0
ProcQueryTree(ClientPtr client) { xQueryTreeReply reply; int rc, numChildren = 0; WindowPtr pChild, pWin, pHead; Window *childIDs = (Window *) NULL; REQUEST(xResourceReq); REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess); if (rc != Success) return rc; reply = (xQueryTreeReply) { .type = X_Reply, .sequenceNumber = client->sequence, .root = pWin->drawable.pScreen->root->drawable.id, .parent = (pWin->parent) ? pWin->parent->drawable.id : (Window) None }; pHead = RealChildHead(pWin); for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) numChildren++; if (numChildren) { int curChild = 0; childIDs = malloc(numChildren * sizeof(Window)); if (!childIDs) return BadAlloc; for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) childIDs[curChild++] = pChild->drawable.id; } reply.nChildren = numChildren; reply.length = bytes_to_int32(numChildren * sizeof(Window)); WriteReplyToClient(client, sizeof(xQueryTreeReply), &reply); if (numChildren) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); free(childIDs); } return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,052
ProcReparentWindow(ClientPtr client) { WindowPtr pWin, pParent; REQUEST(xReparentWindowReq); int rc; REQUEST_SIZE_MATCH(xReparentWindowReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess); if (rc != Success) return rc; rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess); if (rc != Success) return rc; if (!SAME_SCREENS(pWin->drawable, pParent->drawable)) return BadMatch; if ((pWin->backgroundState == ParentRelative) && (pParent->drawable.depth != pWin->drawable.depth)) return BadMatch; if ((pWin->drawable.class != InputOnly) && (pParent->drawable.class == InputOnly)) return BadMatch; return ReparentWindow(pWin, pParent, (short) stuff->x, (short) stuff->y, client); }
DoS
0
ProcReparentWindow(ClientPtr client) { WindowPtr pWin, pParent; REQUEST(xReparentWindowReq); int rc; REQUEST_SIZE_MATCH(xReparentWindowReq); rc = dixLookupWindow(&pWin, stuff->window, client, DixManageAccess); if (rc != Success) return rc; rc = dixLookupWindow(&pParent, stuff->parent, client, DixAddAccess); if (rc != Success) return rc; if (!SAME_SCREENS(pWin->drawable, pParent->drawable)) return BadMatch; if ((pWin->backgroundState == ParentRelative) && (pParent->drawable.depth != pWin->drawable.depth)) return BadMatch; if ((pWin->drawable.class != InputOnly) && (pParent->drawable.class == InputOnly)) return BadMatch; return ReparentWindow(pWin, pParent, (short) stuff->x, (short) stuff->y, client); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,053
ProcSetClipRectangles(ClientPtr client) { int nr, result; GC *pGC; REQUEST(xSetClipRectanglesReq); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) && (stuff->ordering != YXSorted) && (stuff->ordering != YXBanded)) { client->errorValue = stuff->ordering; return BadValue; } result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess); if (result != Success) return result; nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq); if (nr & 4) return BadLength; nr >>= 3; return SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin, nr, (xRectangle *) &stuff[1], (int) stuff->ordering); }
DoS
0
ProcSetClipRectangles(ClientPtr client) { int nr, result; GC *pGC; REQUEST(xSetClipRectanglesReq); REQUEST_AT_LEAST_SIZE(xSetClipRectanglesReq); if ((stuff->ordering != Unsorted) && (stuff->ordering != YSorted) && (stuff->ordering != YXSorted) && (stuff->ordering != YXBanded)) { client->errorValue = stuff->ordering; return BadValue; } result = dixLookupGC(&pGC, stuff->gc, client, DixSetAttrAccess); if (result != Success) return result; nr = (client->req_len << 2) - sizeof(xSetClipRectanglesReq); if (nr & 4) return BadLength; nr >>= 3; return SetClipRects(pGC, stuff->xOrigin, stuff->yOrigin, nr, (xRectangle *) &stuff[1], (int) stuff->ordering); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,054
ProcSetScreenSaver(ClientPtr client) { int rc, i, blankingOption, exposureOption; REQUEST(xSetScreenSaverReq); REQUEST_SIZE_MATCH(xSetScreenSaverReq); for (i = 0; i < screenInfo.numScreens; i++) { rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], DixSetAttrAccess); if (rc != Success) return rc; } blankingOption = stuff->preferBlank; if ((blankingOption != DontPreferBlanking) && (blankingOption != PreferBlanking) && (blankingOption != DefaultBlanking)) { client->errorValue = blankingOption; return BadValue; } exposureOption = stuff->allowExpose; if ((exposureOption != DontAllowExposures) && (exposureOption != AllowExposures) && (exposureOption != DefaultExposures)) { client->errorValue = exposureOption; return BadValue; } if (stuff->timeout < -1) { client->errorValue = stuff->timeout; return BadValue; } if (stuff->interval < -1) { client->errorValue = stuff->interval; return BadValue; } if (blankingOption == DefaultBlanking) ScreenSaverBlanking = defaultScreenSaverBlanking; else ScreenSaverBlanking = blankingOption; if (exposureOption == DefaultExposures) ScreenSaverAllowExposures = defaultScreenSaverAllowExposures; else ScreenSaverAllowExposures = exposureOption; if (stuff->timeout >= 0) ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND; else ScreenSaverTime = defaultScreenSaverTime; if (stuff->interval >= 0) ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND; else ScreenSaverInterval = defaultScreenSaverInterval; SetScreenSaverTimer(); return Success; }
DoS
0
ProcSetScreenSaver(ClientPtr client) { int rc, i, blankingOption, exposureOption; REQUEST(xSetScreenSaverReq); REQUEST_SIZE_MATCH(xSetScreenSaverReq); for (i = 0; i < screenInfo.numScreens; i++) { rc = XaceHook(XACE_SCREENSAVER_ACCESS, client, screenInfo.screens[i], DixSetAttrAccess); if (rc != Success) return rc; } blankingOption = stuff->preferBlank; if ((blankingOption != DontPreferBlanking) && (blankingOption != PreferBlanking) && (blankingOption != DefaultBlanking)) { client->errorValue = blankingOption; return BadValue; } exposureOption = stuff->allowExpose; if ((exposureOption != DontAllowExposures) && (exposureOption != AllowExposures) && (exposureOption != DefaultExposures)) { client->errorValue = exposureOption; return BadValue; } if (stuff->timeout < -1) { client->errorValue = stuff->timeout; return BadValue; } if (stuff->interval < -1) { client->errorValue = stuff->interval; return BadValue; } if (blankingOption == DefaultBlanking) ScreenSaverBlanking = defaultScreenSaverBlanking; else ScreenSaverBlanking = blankingOption; if (exposureOption == DefaultExposures) ScreenSaverAllowExposures = defaultScreenSaverAllowExposures; else ScreenSaverAllowExposures = exposureOption; if (stuff->timeout >= 0) ScreenSaverTime = stuff->timeout * MILLI_PER_SECOND; else ScreenSaverTime = defaultScreenSaverTime; if (stuff->interval >= 0) ScreenSaverInterval = stuff->interval * MILLI_PER_SECOND; else ScreenSaverInterval = defaultScreenSaverInterval; SetScreenSaverTimer(); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,055
ProcStoreColors(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xStoreColorsReq); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixWriteAccess); if (rc == Success) { int count; count = (client->req_len << 2) - sizeof(xStoreColorsReq); if (count % sizeof(xColorItem)) return BadLength; count /= sizeof(xColorItem); return StoreColors(pcmp, count, (xColorItem *) &stuff[1], client); } else { client->errorValue = stuff->cmap; return rc; } }
DoS
0
ProcStoreColors(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xStoreColorsReq); REQUEST_AT_LEAST_SIZE(xStoreColorsReq); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixWriteAccess); if (rc == Success) { int count; count = (client->req_len << 2) - sizeof(xStoreColorsReq); if (count % sizeof(xColorItem)) return BadLength; count /= sizeof(xColorItem); return StoreColors(pcmp, count, (xColorItem *) &stuff[1], client); } else { client->errorValue = stuff->cmap; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,056
ProcStoreNamedColor(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xStoreNamedColorReq); REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixWriteAccess); if (rc == Success) { xColorItem def; if (OsLookupColor(pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes, &def.red, &def.green, &def.blue)) { def.flags = stuff->flags; def.pixel = stuff->pixel; return StoreColors(pcmp, 1, &def, client); } return BadName; } else { client->errorValue = stuff->cmap; return rc; } }
DoS
0
ProcStoreNamedColor(ClientPtr client) { ColormapPtr pcmp; int rc; REQUEST(xStoreNamedColorReq); REQUEST_FIXED_SIZE(xStoreNamedColorReq, stuff->nbytes); rc = dixLookupResourceByType((void **) &pcmp, stuff->cmap, RT_COLORMAP, client, DixWriteAccess); if (rc == Success) { xColorItem def; if (OsLookupColor(pcmp->pScreen->myNum, (char *) &stuff[1], stuff->nbytes, &def.red, &def.green, &def.blue)) { def.flags = stuff->flags; def.pixel = stuff->pixel; return StoreColors(pcmp, 1, &def, client); } return BadName; } else { client->errorValue = stuff->cmap; return rc; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,057
ProcTranslateCoords(ClientPtr client) { REQUEST(xTranslateCoordsReq); WindowPtr pWin, pDst; xTranslateCoordsReply rep; int rc; REQUEST_SIZE_MATCH(xTranslateCoordsReq); rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixGetAttrAccess); if (rc != Success) return rc; rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixGetAttrAccess); if (rc != Success) return rc; rep = (xTranslateCoordsReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0 }; if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) { rep.sameScreen = xFalse; rep.child = None; rep.dstX = rep.dstY = 0; } else { INT16 x, y; rep.sameScreen = xTrue; rep.child = None; /* computing absolute coordinates -- adjust to destination later */ x = pWin->drawable.x + stuff->srcX; y = pWin->drawable.y + stuff->srcY; pWin = pDst->firstChild; while (pWin) { BoxRec box; if ((pWin->mapped) && (x >= pWin->drawable.x - wBorderWidth(pWin)) && (x < pWin->drawable.x + (int) pWin->drawable.width + wBorderWidth(pWin)) && (y >= pWin->drawable.y - wBorderWidth(pWin)) && (y < pWin->drawable.y + (int) pWin->drawable.height + wBorderWidth(pWin)) /* When a window is shaped, a further check * is made to see if the point is inside * borderSize */ && (!wBoundingShape(pWin) || RegionContainsPoint(&pWin->borderSize, x, y, &box)) && (!wInputShape(pWin) || RegionContainsPoint(wInputShape(pWin), x - pWin->drawable.x, y - pWin->drawable.y, &box)) ) { rep.child = pWin->drawable.id; pWin = (WindowPtr) NULL; } else pWin = pWin->nextSib; } /* adjust to destination coordinates */ rep.dstX = x - pDst->drawable.x; rep.dstY = y - pDst->drawable.y; } WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); return Success; }
DoS
0
ProcTranslateCoords(ClientPtr client) { REQUEST(xTranslateCoordsReq); WindowPtr pWin, pDst; xTranslateCoordsReply rep; int rc; REQUEST_SIZE_MATCH(xTranslateCoordsReq); rc = dixLookupWindow(&pWin, stuff->srcWid, client, DixGetAttrAccess); if (rc != Success) return rc; rc = dixLookupWindow(&pDst, stuff->dstWid, client, DixGetAttrAccess); if (rc != Success) return rc; rep = (xTranslateCoordsReply) { .type = X_Reply, .sequenceNumber = client->sequence, .length = 0 }; if (!SAME_SCREENS(pWin->drawable, pDst->drawable)) { rep.sameScreen = xFalse; rep.child = None; rep.dstX = rep.dstY = 0; } else { INT16 x, y; rep.sameScreen = xTrue; rep.child = None; /* computing absolute coordinates -- adjust to destination later */ x = pWin->drawable.x + stuff->srcX; y = pWin->drawable.y + stuff->srcY; pWin = pDst->firstChild; while (pWin) { BoxRec box; if ((pWin->mapped) && (x >= pWin->drawable.x - wBorderWidth(pWin)) && (x < pWin->drawable.x + (int) pWin->drawable.width + wBorderWidth(pWin)) && (y >= pWin->drawable.y - wBorderWidth(pWin)) && (y < pWin->drawable.y + (int) pWin->drawable.height + wBorderWidth(pWin)) /* When a window is shaped, a further check * is made to see if the point is inside * borderSize */ && (!wBoundingShape(pWin) || RegionContainsPoint(&pWin->borderSize, x, y, &box)) && (!wInputShape(pWin) || RegionContainsPoint(wInputShape(pWin), x - pWin->drawable.x, y - pWin->drawable.y, &box)) ) { rep.child = pWin->drawable.id; pWin = (WindowPtr) NULL; } else pWin = pWin->nextSib; } /* adjust to destination coordinates */ rep.dstX = x - pDst->drawable.x; rep.dstY = y - pDst->drawable.y; } WriteReplyToClient(client, sizeof(xTranslateCoordsReply), &rep); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,058
ProcUngrabServer(ClientPtr client) { REQUEST_SIZE_MATCH(xReq); UngrabServer(client); return Success; }
DoS
0
ProcUngrabServer(ClientPtr client) { REQUEST_SIZE_MATCH(xReq); UngrabServer(client); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,059
ProcUnmapSubwindows(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess); if (rc != Success) return rc; UnmapSubwindows(pWin); return Success; }
DoS
0
ProcUnmapSubwindows(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixListAccess); if (rc != Success) return rc; UnmapSubwindows(pWin); return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,060
ProcUnmapWindow(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixHideAccess); if (rc != Success) return rc; UnmapWindow(pWin, FALSE); /* update cache to say it is mapped */ return Success; }
DoS
0
ProcUnmapWindow(ClientPtr client) { WindowPtr pWin; REQUEST(xResourceReq); int rc; REQUEST_SIZE_MATCH(xResourceReq); rc = dixLookupWindow(&pWin, stuff->id, client, DixHideAccess); if (rc != Success) return rc; UnmapWindow(pWin, FALSE); /* update cache to say it is mapped */ return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,061
ReformatImage(char *base, int nbytes, int bpp, int order) { switch (bpp) { case 1: /* yuck */ if (BITMAP_BIT_ORDER != order) BitOrderInvert((unsigned char *) base, nbytes); #if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8 ReformatImage(base, nbytes, BITMAP_SCANLINE_UNIT, order); #endif break; case 4: break; /* yuck */ case 8: break; case 16: if (IMAGE_BYTE_ORDER != order) TwoByteSwap((unsigned char *) base, nbytes); break; case 32: if (IMAGE_BYTE_ORDER != order) FourByteSwap((unsigned char *) base, nbytes); break; } }
DoS
0
ReformatImage(char *base, int nbytes, int bpp, int order) { switch (bpp) { case 1: /* yuck */ if (BITMAP_BIT_ORDER != order) BitOrderInvert((unsigned char *) base, nbytes); #if IMAGE_BYTE_ORDER != BITMAP_BIT_ORDER && BITMAP_SCANLINE_UNIT != 8 ReformatImage(base, nbytes, BITMAP_SCANLINE_UNIT, order); #endif break; case 4: break; /* yuck */ case 8: break; case 16: if (IMAGE_BYTE_ORDER != order) TwoByteSwap((unsigned char *) base, nbytes); break; case 32: if (IMAGE_BYTE_ORDER != order) FourByteSwap((unsigned char *) base, nbytes); break; } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,062
SendConnSetup(ClientPtr client, const char *reason) { xWindowRoot *root; int i; int numScreens; char *lConnectionInfo; xConnSetupPrefix *lconnSetupPrefix; if (reason) { xConnSetupPrefix csp; csp.success = xFalse; csp.lengthReason = strlen(reason); csp.length = bytes_to_int32(csp.lengthReason); csp.majorVersion = X_PROTOCOL; csp.minorVersion = X_PROTOCOL_REVISION; if (client->swapped) WriteSConnSetupPrefix(client, &csp); else WriteToClient(client, sz_xConnSetupPrefix, &csp); WriteToClient(client, (int) csp.lengthReason, reason); return client->noClientException = -1; } numScreens = screenInfo.numScreens; lConnectionInfo = ConnectionInfo; lconnSetupPrefix = &connSetupPrefix; /* We're about to start speaking X protocol back to the client by * sending the connection setup info. This means the authorization * step is complete, and we can count the client as an * authorized one. */ nClients++; client->requestVector = client->swapped ? SwappedProcVector : ProcVector; client->sequence = 0; ((xConnSetup *) lConnectionInfo)->ridBase = client->clientAsMask; ((xConnSetup *) lConnectionInfo)->ridMask = RESOURCE_ID_MASK; #ifdef MATCH_CLIENT_ENDIAN ((xConnSetup *) lConnectionInfo)->imageByteOrder = ClientOrder(client); ((xConnSetup *) lConnectionInfo)->bitmapBitOrder = ClientOrder(client); #endif /* fill in the "currentInputMask" */ root = (xWindowRoot *) (lConnectionInfo + connBlockScreenStart); #ifdef PANORAMIX if (noPanoramiXExtension) numScreens = screenInfo.numScreens; else numScreens = ((xConnSetup *) ConnectionInfo)->numRoots; #endif for (i = 0; i < numScreens; i++) { unsigned int j; xDepth *pDepth; WindowPtr pRoot = screenInfo.screens[i]->root; root->currentInputMask = pRoot->eventMask | wOtherEventMasks(pRoot); pDepth = (xDepth *) (root + 1); for (j = 0; j < root->nDepths; j++) { pDepth = (xDepth *) (((char *) (pDepth + 1)) + pDepth->nVisuals * sizeof(xVisualType)); } root = (xWindowRoot *) pDepth; } if (client->swapped) { WriteSConnSetupPrefix(client, lconnSetupPrefix); WriteSConnectionInfo(client, (unsigned long) (lconnSetupPrefix->length << 2), lConnectionInfo); } else { WriteToClient(client, sizeof(xConnSetupPrefix), lconnSetupPrefix); WriteToClient(client, (int) (lconnSetupPrefix->length << 2), lConnectionInfo); } client->clientState = ClientStateRunning; if (ClientStateCallback) { NewClientInfoRec clientinfo; clientinfo.client = client; clientinfo.prefix = lconnSetupPrefix; clientinfo.setup = (xConnSetup *) lConnectionInfo; CallCallbacks((&ClientStateCallback), (void *) &clientinfo); } return Success; }
DoS
0
SendConnSetup(ClientPtr client, const char *reason) { xWindowRoot *root; int i; int numScreens; char *lConnectionInfo; xConnSetupPrefix *lconnSetupPrefix; if (reason) { xConnSetupPrefix csp; csp.success = xFalse; csp.lengthReason = strlen(reason); csp.length = bytes_to_int32(csp.lengthReason); csp.majorVersion = X_PROTOCOL; csp.minorVersion = X_PROTOCOL_REVISION; if (client->swapped) WriteSConnSetupPrefix(client, &csp); else WriteToClient(client, sz_xConnSetupPrefix, &csp); WriteToClient(client, (int) csp.lengthReason, reason); return client->noClientException = -1; } numScreens = screenInfo.numScreens; lConnectionInfo = ConnectionInfo; lconnSetupPrefix = &connSetupPrefix; /* We're about to start speaking X protocol back to the client by * sending the connection setup info. This means the authorization * step is complete, and we can count the client as an * authorized one. */ nClients++; client->requestVector = client->swapped ? SwappedProcVector : ProcVector; client->sequence = 0; ((xConnSetup *) lConnectionInfo)->ridBase = client->clientAsMask; ((xConnSetup *) lConnectionInfo)->ridMask = RESOURCE_ID_MASK; #ifdef MATCH_CLIENT_ENDIAN ((xConnSetup *) lConnectionInfo)->imageByteOrder = ClientOrder(client); ((xConnSetup *) lConnectionInfo)->bitmapBitOrder = ClientOrder(client); #endif /* fill in the "currentInputMask" */ root = (xWindowRoot *) (lConnectionInfo + connBlockScreenStart); #ifdef PANORAMIX if (noPanoramiXExtension) numScreens = screenInfo.numScreens; else numScreens = ((xConnSetup *) ConnectionInfo)->numRoots; #endif for (i = 0; i < numScreens; i++) { unsigned int j; xDepth *pDepth; WindowPtr pRoot = screenInfo.screens[i]->root; root->currentInputMask = pRoot->eventMask | wOtherEventMasks(pRoot); pDepth = (xDepth *) (root + 1); for (j = 0; j < root->nDepths; j++) { pDepth = (xDepth *) (((char *) (pDepth + 1)) + pDepth->nVisuals * sizeof(xVisualType)); } root = (xWindowRoot *) pDepth; } if (client->swapped) { WriteSConnSetupPrefix(client, lconnSetupPrefix); WriteSConnectionInfo(client, (unsigned long) (lconnSetupPrefix->length << 2), lConnectionInfo); } else { WriteToClient(client, sizeof(xConnSetupPrefix), lconnSetupPrefix); WriteToClient(client, (int) (lconnSetupPrefix->length << 2), lConnectionInfo); } client->clientState = ClientStateRunning; if (ClientStateCallback) { NewClientInfoRec clientinfo; clientinfo.client = client; clientinfo.prefix = lconnSetupPrefix; clientinfo.setup = (xConnSetup *) lConnectionInfo; CallCallbacks((&ClientStateCallback), (void *) &clientinfo); } return Success; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,063
SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode, XID resId, int errorCode) { xError rep = { .type = X_Error, .errorCode = errorCode, .resourceID = resId, .minorCode = minorCode, .majorCode = majorCode }; WriteEventsToClient(client, 1, (xEvent *) &rep); }
DoS
0
SendErrorToClient(ClientPtr client, unsigned majorCode, unsigned minorCode, XID resId, int errorCode) { xError rep = { .type = X_Error, .errorCode = errorCode, .resourceID = resId, .minorCode = minorCode, .majorCode = majorCode }; WriteEventsToClient(client, 1, (xEvent *) &rep); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,064
ServerOrder(void) { int whichbyte = 1; if (*((char *) &whichbyte)) return LSBFirst; return MSBFirst; }
DoS
0
ServerOrder(void) { int whichbyte = 1; if (*((char *) &whichbyte)) return LSBFirst; return MSBFirst; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,065
SetVendorRelease(int release) { VendorRelease = release; }
DoS
0
SetVendorRelease(int release) { VendorRelease = release; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,066
SetVendorString(const char *vendor) { VendorString = vendor; }
DoS
0
SetVendorString(const char *vendor) { VendorString = vendor; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,067
SmartScheduleClient(int *clientReady, int nready) { ClientPtr pClient; int i; int client; int bestPrio, best = 0; int bestRobin, robin; long now = SmartScheduleTime; long idle; bestPrio = -0x7fffffff; bestRobin = 0; idle = 2 * SmartScheduleSlice; for (i = 0; i < nready; i++) { client = clientReady[i]; pClient = clients[client]; /* Praise clients which haven't run in a while */ if ((now - pClient->smart_stop_tick) >= idle) { if (pClient->smart_priority < 0) pClient->smart_priority++; } /* check priority to select best client */ robin = (pClient->index - SmartLastIndex[pClient->smart_priority - SMART_MIN_PRIORITY]) & 0xff; if (pClient->smart_priority > bestPrio || (pClient->smart_priority == bestPrio && robin > bestRobin)) { bestPrio = pClient->smart_priority; bestRobin = robin; best = client; } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) fprintf(stderr, " %2d: %3d", client, pClient->smart_priority); #endif } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) { fprintf(stderr, " use %2d\n", best); SmartLastPrint = now; } #endif pClient = clients[best]; SmartLastIndex[bestPrio - SMART_MIN_PRIORITY] = pClient->index; /* * Set current client pointer */ if (SmartLastClient != pClient) { pClient->smart_start_tick = now; SmartLastClient = pClient; } /* * Adjust slice */ if (nready == 1 && SmartScheduleLatencyLimited == 0) { /* * If it's been a long time since another client * has run, bump the slice up to get maximal * performance from a single client */ if ((now - pClient->smart_start_tick) > 1000 && SmartScheduleSlice < SmartScheduleMaxSlice) { SmartScheduleSlice += SmartScheduleInterval; } } else { SmartScheduleSlice = SmartScheduleInterval; } return best; }
DoS
0
SmartScheduleClient(int *clientReady, int nready) { ClientPtr pClient; int i; int client; int bestPrio, best = 0; int bestRobin, robin; long now = SmartScheduleTime; long idle; bestPrio = -0x7fffffff; bestRobin = 0; idle = 2 * SmartScheduleSlice; for (i = 0; i < nready; i++) { client = clientReady[i]; pClient = clients[client]; /* Praise clients which haven't run in a while */ if ((now - pClient->smart_stop_tick) >= idle) { if (pClient->smart_priority < 0) pClient->smart_priority++; } /* check priority to select best client */ robin = (pClient->index - SmartLastIndex[pClient->smart_priority - SMART_MIN_PRIORITY]) & 0xff; if (pClient->smart_priority > bestPrio || (pClient->smart_priority == bestPrio && robin > bestRobin)) { bestPrio = pClient->smart_priority; bestRobin = robin; best = client; } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) fprintf(stderr, " %2d: %3d", client, pClient->smart_priority); #endif } #ifdef SMART_DEBUG if ((now - SmartLastPrint) >= 5000) { fprintf(stderr, " use %2d\n", best); SmartLastPrint = now; } #endif pClient = clients[best]; SmartLastIndex[bestPrio - SMART_MIN_PRIORITY] = pClient->index; /* * Set current client pointer */ if (SmartLastClient != pClient) { pClient->smart_start_tick = now; SmartLastClient = pClient; } /* * Adjust slice */ if (nready == 1 && SmartScheduleLatencyLimited == 0) { /* * If it's been a long time since another client * has run, bump the slice up to get maximal * performance from a single client */ if ((now - pClient->smart_start_tick) > 1000 && SmartScheduleSlice < SmartScheduleMaxSlice) { SmartScheduleSlice += SmartScheduleInterval; } } else { SmartScheduleSlice = SmartScheduleInterval; } return best; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,068
UngrabServer(ClientPtr client) { int i; grabState = GrabNone; ListenToAllClients(); for (i = mskcnt; --i >= 0 && !grabWaiters[i];); if (i >= 0) { i <<= 5; while (!GETBIT(grabWaiters, i)) i++; BITCLEAR(grabWaiters, i); AttendClient(clients[i]); } if (ServerGrabCallback) { ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_UNGRABBED; CallCallbacks(&ServerGrabCallback, (void *) &grabinfo); } }
DoS
0
UngrabServer(ClientPtr client) { int i; grabState = GrabNone; ListenToAllClients(); for (i = mskcnt; --i >= 0 && !grabWaiters[i];); if (i >= 0) { i <<= 5; while (!GETBIT(grabWaiters, i)) i++; BITCLEAR(grabWaiters, i); AttendClient(clients[i]); } if (ServerGrabCallback) { ServerGrabInfoRec grabinfo; grabinfo.client = client; grabinfo.grabstate = SERVER_UNGRABBED; CallCallbacks(&ServerGrabCallback, (void *) &grabinfo); } }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,069
UpdateCurrentTime(void) { TimeStamp systime; /* To avoid time running backwards, we must call GetTimeInMillis before * calling ProcessInputEvents. */ systime.months = currentTime.months; systime.milliseconds = GetTimeInMillis(); if (systime.milliseconds < currentTime.milliseconds) systime.months++; if (*checkForInput[0] != *checkForInput[1]) ProcessInputEvents(); if (CompareTimeStamps(systime, currentTime) == LATER) currentTime = systime; }
DoS
0
UpdateCurrentTime(void) { TimeStamp systime; /* To avoid time running backwards, we must call GetTimeInMillis before * calling ProcessInputEvents. */ systime.months = currentTime.months; systime.milliseconds = GetTimeInMillis(); if (systime.milliseconds < currentTime.milliseconds) systime.months++; if (*checkForInput[0] != *checkForInput[1]) ProcessInputEvents(); if (CompareTimeStamps(systime, currentTime) == LATER) currentTime = systime; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,070
dixDestroyPixmap(void *value, XID pid) { PixmapPtr pPixmap = (PixmapPtr) value; return (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap); }
DoS
0
dixDestroyPixmap(void *value, XID pid) { PixmapPtr pPixmap = (PixmapPtr) value; return (*pPixmap->drawable.pScreen->DestroyPixmap) (pPixmap); }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,071
static int init_screen(ScreenPtr pScreen, int i, Bool gpu) { int scanlinepad, format, depth, bitsPerPixel, j, k; dixInitScreenSpecificPrivates(pScreen); if (!dixAllocatePrivates(&pScreen->devPrivates, PRIVATE_SCREEN)) { return -1; } pScreen->myNum = i; if (gpu) { pScreen->myNum += GPU_SCREEN_OFFSET; pScreen->isGPU = TRUE; } pScreen->totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */ pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ pScreen->CreateScreenResources = 0; xorg_list_init(&pScreen->pixmap_dirty_list); xorg_list_init(&pScreen->unattached_list); xorg_list_init(&pScreen->output_slave_list); xorg_list_init(&pScreen->offload_slave_list); /* * This loop gets run once for every Screen that gets added, * but thats ok. If the ddx layer initializes the formats * one at a time calling AddScreen() after each, then each * iteration will make it a little more accurate. Worst case * we do this loop N * numPixmapFormats where N is # of screens. * Anyway, this must be called after InitOutput and before the * screen init routine is called. */ for (format = 0; format < screenInfo.numPixmapFormats; format++) { depth = screenInfo.formats[format].depth; bitsPerPixel = screenInfo.formats[format].bitsPerPixel; scanlinepad = screenInfo.formats[format].scanlinePad; j = indexForBitsPerPixel[bitsPerPixel]; k = indexForScanlinePad[scanlinepad]; PixmapWidthPaddingInfo[depth].padPixelsLog2 = answer[j][k]; PixmapWidthPaddingInfo[depth].padRoundUp = (scanlinepad / bitsPerPixel) - 1; j = indexForBitsPerPixel[8]; /* bits per byte */ PixmapWidthPaddingInfo[depth].padBytesLog2 = answer[j][k]; PixmapWidthPaddingInfo[depth].bitsPerPixel = bitsPerPixel; if (answerBytesPerPixel[bitsPerPixel]) { PixmapWidthPaddingInfo[depth].notPower2 = 1; PixmapWidthPaddingInfo[depth].bytesPerPixel = answerBytesPerPixel[bitsPerPixel]; } else { PixmapWidthPaddingInfo[depth].notPower2 = 0; } } return 0; }
DoS
0
static int init_screen(ScreenPtr pScreen, int i, Bool gpu) { int scanlinepad, format, depth, bitsPerPixel, j, k; dixInitScreenSpecificPrivates(pScreen); if (!dixAllocatePrivates(&pScreen->devPrivates, PRIVATE_SCREEN)) { return -1; } pScreen->myNum = i; if (gpu) { pScreen->myNum += GPU_SCREEN_OFFSET; pScreen->isGPU = TRUE; } pScreen->totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */ pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ pScreen->CreateScreenResources = 0; xorg_list_init(&pScreen->pixmap_dirty_list); xorg_list_init(&pScreen->unattached_list); xorg_list_init(&pScreen->output_slave_list); xorg_list_init(&pScreen->offload_slave_list); /* * This loop gets run once for every Screen that gets added, * but thats ok. If the ddx layer initializes the formats * one at a time calling AddScreen() after each, then each * iteration will make it a little more accurate. Worst case * we do this loop N * numPixmapFormats where N is # of screens. * Anyway, this must be called after InitOutput and before the * screen init routine is called. */ for (format = 0; format < screenInfo.numPixmapFormats; format++) { depth = screenInfo.formats[format].depth; bitsPerPixel = screenInfo.formats[format].bitsPerPixel; scanlinepad = screenInfo.formats[format].scanlinePad; j = indexForBitsPerPixel[bitsPerPixel]; k = indexForScanlinePad[scanlinepad]; PixmapWidthPaddingInfo[depth].padPixelsLog2 = answer[j][k]; PixmapWidthPaddingInfo[depth].padRoundUp = (scanlinepad / bitsPerPixel) - 1; j = indexForBitsPerPixel[8]; /* bits per byte */ PixmapWidthPaddingInfo[depth].padBytesLog2 = answer[j][k]; PixmapWidthPaddingInfo[depth].bitsPerPixel = bitsPerPixel; if (answerBytesPerPixel[bitsPerPixel]) { PixmapWidthPaddingInfo[depth].notPower2 = 1; PixmapWidthPaddingInfo[depth].bytesPerPixel = answerBytesPerPixel[bitsPerPixel]; } else { PixmapWidthPaddingInfo[depth].notPower2 = 0; } } return 0; }
@@ -2000,7 +2000,7 @@ ProcPutImage(ClientPtr client) tmpImage = (char *) &stuff[1]; lengthProto = length; - if (lengthProto >= (INT32_MAX / stuff->height)) + if (stuff->height != 0 && lengthProto >= (INT32_MAX / stuff->height)) return BadLength; if ((bytes_to_int32(lengthProto * stuff->height) +
CWE-369
null
null
12,072
PHP_FUNCTION(dom_document_create_document_fragment) { zval *id; xmlNode *node; xmlDocPtr docp; dom_object *intern; int ret; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, dom_document_class_entry) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); node = xmlNewDocFragment(docp); if (!node) { RETURN_FALSE; } DOM_RET_OBJ(node, &ret, intern); }
Bypass
0
PHP_FUNCTION(dom_document_create_document_fragment) { zval *id; xmlNode *node; xmlDocPtr docp; dom_object *intern; int ret; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O", &id, dom_document_class_entry) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); node = xmlNewDocFragment(docp); if (!node) { RETURN_FALSE; } DOM_RET_OBJ(node, &ret, intern); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,073
PHP_FUNCTION(dom_document_create_text_node) { zval *id; xmlNode *node; xmlDocPtr docp; int ret, value_len; dom_object *intern; char *value; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); node = xmlNewDocText(docp, (xmlChar *) value); if (!node) { RETURN_FALSE; } DOM_RET_OBJ(node, &ret, intern); }
Bypass
0
PHP_FUNCTION(dom_document_create_text_node) { zval *id; xmlNode *node; xmlDocPtr docp; int ret, value_len; dom_object *intern; char *value; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); node = xmlNewDocText(docp, (xmlChar *) value); if (!node) { RETURN_FALSE; } DOM_RET_OBJ(node, &ret, intern); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,074
PHP_FUNCTION(dom_document_create_comment) { zval *id; xmlNode *node; xmlDocPtr docp; int ret, value_len; dom_object *intern; char *value; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); node = xmlNewDocComment(docp, (xmlChar *) value); if (!node) { RETURN_FALSE; } DOM_RET_OBJ(node, &ret, intern); }
Bypass
0
PHP_FUNCTION(dom_document_create_comment) { zval *id; xmlNode *node; xmlDocPtr docp; int ret, value_len; dom_object *intern; char *value; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); node = xmlNewDocComment(docp, (xmlChar *) value); if (!node) { RETURN_FALSE; } DOM_RET_OBJ(node, &ret, intern); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,075
PHP_FUNCTION(dom_document_create_cdatasection) { zval *id; xmlNode *node; xmlDocPtr docp; int ret, value_len; dom_object *intern; char *value; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); node = xmlNewCDataBlock(docp, (xmlChar *) value, value_len); if (!node) { RETURN_FALSE; } DOM_RET_OBJ(node, &ret, intern); }
Bypass
0
PHP_FUNCTION(dom_document_create_cdatasection) { zval *id; xmlNode *node; xmlDocPtr docp; int ret, value_len; dom_object *intern; char *value; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); node = xmlNewCDataBlock(docp, (xmlChar *) value, value_len); if (!node) { RETURN_FALSE; } DOM_RET_OBJ(node, &ret, intern); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,076
PHP_FUNCTION(dom_document_create_attribute) { zval *id; xmlAttrPtr node; xmlDocPtr docp; int ret, name_len; dom_object *intern; char *name; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); if (xmlValidateName((xmlChar *) name, 0) != 0) { php_dom_throw_error(INVALID_CHARACTER_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } node = xmlNewDocProp(docp, (xmlChar *) name, NULL); if (!node) { RETURN_FALSE; } DOM_RET_OBJ((xmlNodePtr) node, &ret, intern); }
Bypass
0
PHP_FUNCTION(dom_document_create_attribute) { zval *id; xmlAttrPtr node; xmlDocPtr docp; int ret, name_len; dom_object *intern; char *name; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); if (xmlValidateName((xmlChar *) name, 0) != 0) { php_dom_throw_error(INVALID_CHARACTER_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } node = xmlNewDocProp(docp, (xmlChar *) name, NULL); if (!node) { RETURN_FALSE; } DOM_RET_OBJ((xmlNodePtr) node, &ret, intern); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,077
PHP_FUNCTION(dom_document_create_entity_reference) { zval *id; xmlNode *node; xmlDocPtr docp = NULL; dom_object *intern; int ret, name_len; char *name; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); if (xmlValidateName((xmlChar *) name, 0) != 0) { php_dom_throw_error(INVALID_CHARACTER_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } node = xmlNewReference(docp, name); if (!node) { RETURN_FALSE; } DOM_RET_OBJ((xmlNodePtr) node, &ret, intern); }
Bypass
0
PHP_FUNCTION(dom_document_create_entity_reference) { zval *id; xmlNode *node; xmlDocPtr docp = NULL; dom_object *intern; int ret, name_len; char *name; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); if (xmlValidateName((xmlChar *) name, 0) != 0) { php_dom_throw_error(INVALID_CHARACTER_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } node = xmlNewReference(docp, name); if (!node) { RETURN_FALSE; } DOM_RET_OBJ((xmlNodePtr) node, &ret, intern); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,078
PHP_FUNCTION(dom_document_get_elements_by_tag_name) { zval *id; xmlDocPtr docp; int name_len; dom_object *intern, *namednode; char *name; xmlChar *local; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); local = xmlCharStrndup(name, name_len); dom_namednode_iter(intern, 0, namednode, NULL, local, NULL TSRMLS_CC); }
Bypass
0
PHP_FUNCTION(dom_document_get_elements_by_tag_name) { zval *id; xmlDocPtr docp; int name_len; dom_object *intern, *namednode; char *name; xmlChar *local; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); local = xmlCharStrndup(name, name_len); dom_namednode_iter(intern, 0, namednode, NULL, local, NULL TSRMLS_CC); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,079
PHP_FUNCTION(dom_document_import_node) { zval *id, *node; xmlDocPtr docp; xmlNodePtr nodep, retnodep; dom_object *intern, *nodeobj; int ret; long recursive = 0; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO|l", &id, dom_document_class_entry, &node, dom_node_class_entry, &recursive) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); DOM_GET_OBJ(nodep, node, xmlNodePtr, nodeobj); if (nodep->type == XML_HTML_DOCUMENT_NODE || nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_DOCUMENT_TYPE_NODE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot import: Node Type Not Supported"); RETURN_FALSE; } if (nodep->doc == docp) { retnodep = nodep; } else { if ((recursive == 0) && (nodep->type == XML_ELEMENT_NODE)) { recursive = 2; } retnodep = xmlDocCopyNode(nodep, docp, recursive); if (!retnodep) { RETURN_FALSE; } if ((retnodep->type == XML_ATTRIBUTE_NODE) && (nodep->ns != NULL)) { xmlNsPtr nsptr = NULL; xmlNodePtr root = xmlDocGetRootElement(docp); nsptr = xmlSearchNsByHref (nodep->doc, root, nodep->ns->href); if (nsptr == NULL) { int errorcode; nsptr = dom_get_ns(root, (char *) nodep->ns->href, &errorcode, (char *) nodep->ns->prefix); } xmlSetNs(retnodep, nsptr); } } DOM_RET_OBJ((xmlNodePtr) retnodep, &ret, intern); }
Bypass
0
PHP_FUNCTION(dom_document_import_node) { zval *id, *node; xmlDocPtr docp; xmlNodePtr nodep, retnodep; dom_object *intern, *nodeobj; int ret; long recursive = 0; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO|l", &id, dom_document_class_entry, &node, dom_node_class_entry, &recursive) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); DOM_GET_OBJ(nodep, node, xmlNodePtr, nodeobj); if (nodep->type == XML_HTML_DOCUMENT_NODE || nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_DOCUMENT_TYPE_NODE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot import: Node Type Not Supported"); RETURN_FALSE; } if (nodep->doc == docp) { retnodep = nodep; } else { if ((recursive == 0) && (nodep->type == XML_ELEMENT_NODE)) { recursive = 2; } retnodep = xmlDocCopyNode(nodep, docp, recursive); if (!retnodep) { RETURN_FALSE; } if ((retnodep->type == XML_ATTRIBUTE_NODE) && (nodep->ns != NULL)) { xmlNsPtr nsptr = NULL; xmlNodePtr root = xmlDocGetRootElement(docp); nsptr = xmlSearchNsByHref (nodep->doc, root, nodep->ns->href); if (nsptr == NULL) { int errorcode; nsptr = dom_get_ns(root, (char *) nodep->ns->href, &errorcode, (char *) nodep->ns->prefix); } xmlSetNs(retnodep, nsptr); } } DOM_RET_OBJ((xmlNodePtr) retnodep, &ret, intern); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,080
PHP_FUNCTION(dom_document_create_element_ns) { zval *id; xmlDocPtr docp; xmlNodePtr nodep = NULL; xmlNsPtr nsptr = NULL; int ret, uri_len = 0, name_len = 0, value_len = 0; char *uri, *name, *value = NULL; char *localname = NULL, *prefix = NULL; int errorcode; dom_object *intern; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!s|s", &id, dom_document_class_entry, &uri, &uri_len, &name, &name_len, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len); if (errorcode == 0) { if (xmlValidateName((xmlChar *) localname, 0) == 0) { nodep = xmlNewDocNode (docp, NULL, localname, value); if (nodep != NULL && uri != NULL) { nsptr = xmlSearchNsByHref (nodep->doc, nodep, uri); if (nsptr == NULL) { nsptr = dom_get_ns(nodep, uri, &errorcode, prefix); } xmlSetNs(nodep, nsptr); } } else { errorcode = INVALID_CHARACTER_ERR; } } xmlFree(localname); if (prefix != NULL) { xmlFree(prefix); } if (errorcode != 0) { if (nodep != NULL) { xmlFreeNode(nodep); } php_dom_throw_error(errorcode, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } if (nodep == NULL) { RETURN_FALSE; } nodep->ns = nsptr; DOM_RET_OBJ(nodep, &ret, intern); }
Bypass
0
PHP_FUNCTION(dom_document_create_element_ns) { zval *id; xmlDocPtr docp; xmlNodePtr nodep = NULL; xmlNsPtr nsptr = NULL; int ret, uri_len = 0, name_len = 0, value_len = 0; char *uri, *name, *value = NULL; char *localname = NULL, *prefix = NULL; int errorcode; dom_object *intern; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!s|s", &id, dom_document_class_entry, &uri, &uri_len, &name, &name_len, &value, &value_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len); if (errorcode == 0) { if (xmlValidateName((xmlChar *) localname, 0) == 0) { nodep = xmlNewDocNode (docp, NULL, localname, value); if (nodep != NULL && uri != NULL) { nsptr = xmlSearchNsByHref (nodep->doc, nodep, uri); if (nsptr == NULL) { nsptr = dom_get_ns(nodep, uri, &errorcode, prefix); } xmlSetNs(nodep, nsptr); } } else { errorcode = INVALID_CHARACTER_ERR; } } xmlFree(localname); if (prefix != NULL) { xmlFree(prefix); } if (errorcode != 0) { if (nodep != NULL) { xmlFreeNode(nodep); } php_dom_throw_error(errorcode, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } if (nodep == NULL) { RETURN_FALSE; } nodep->ns = nsptr; DOM_RET_OBJ(nodep, &ret, intern); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,081
PHP_FUNCTION(dom_document_get_elements_by_tag_name_ns) { zval *id; xmlDocPtr docp; int uri_len, name_len; dom_object *intern, *namednode; char *uri, *name; xmlChar *local, *nsuri; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss", &id, dom_document_class_entry, &uri, &uri_len, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); local = xmlCharStrndup(name, name_len); nsuri = xmlCharStrndup(uri, uri_len); dom_namednode_iter(intern, 0, namednode, NULL, local, nsuri TSRMLS_CC); }
Bypass
0
PHP_FUNCTION(dom_document_get_elements_by_tag_name_ns) { zval *id; xmlDocPtr docp; int uri_len, name_len; dom_object *intern, *namednode; char *uri, *name; xmlChar *local, *nsuri; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oss", &id, dom_document_class_entry, &uri, &uri_len, &name, &name_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); php_dom_create_interator(return_value, DOM_NODELIST TSRMLS_CC); namednode = (dom_object *)zend_objects_get_address(return_value TSRMLS_CC); local = xmlCharStrndup(name, name_len); nsuri = xmlCharStrndup(uri, uri_len); dom_namednode_iter(intern, 0, namednode, NULL, local, nsuri TSRMLS_CC); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,082
PHP_FUNCTION(dom_document_get_element_by_id) { zval *id; xmlDocPtr docp; xmlAttrPtr attrp; int ret, idname_len; dom_object *intern; char *idname; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &idname, &idname_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); attrp = xmlGetID(docp, (xmlChar *) idname); if (attrp && attrp->parent) { DOM_RET_OBJ((xmlNodePtr) attrp->parent, &ret, intern); } else { RETVAL_NULL(); } }
Bypass
0
PHP_FUNCTION(dom_document_get_element_by_id) { zval *id; xmlDocPtr docp; xmlAttrPtr attrp; int ret, idname_len; dom_object *intern; char *idname; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &idname, &idname_len) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); attrp = xmlGetID(docp, (xmlChar *) idname); if (attrp && attrp->parent) { DOM_RET_OBJ((xmlNodePtr) attrp->parent, &ret, intern); } else { RETVAL_NULL(); } }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,083
PHP_FUNCTION(dom_document_rename_node) { DOM_NOT_IMPLEMENTED(); }
Bypass
0
PHP_FUNCTION(dom_document_rename_node) { DOM_NOT_IMPLEMENTED(); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,084
PHP_FUNCTION(dom_document_save_html_file) { zval *id; xmlDoc *docp; int file_len, bytes, format; dom_object *intern; dom_doc_propsptr doc_props; char *file; const char *encoding; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &file, &file_len) == FAILURE) { return; } if (file_len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Filename"); RETURN_FALSE; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); encoding = (const char *) htmlGetMetaEncoding(docp); doc_props = dom_get_doc_props(intern->document); format = doc_props->formatoutput; bytes = htmlSaveFileFormat(file, docp, encoding, format); if (bytes == -1) { RETURN_FALSE; } RETURN_LONG(bytes); }
Bypass
0
PHP_FUNCTION(dom_document_save_html_file) { zval *id; xmlDoc *docp; int file_len, bytes, format; dom_object *intern; dom_doc_propsptr doc_props; char *file; const char *encoding; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_document_class_entry, &file, &file_len) == FAILURE) { return; } if (file_len == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid Filename"); RETURN_FALSE; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); encoding = (const char *) htmlGetMetaEncoding(docp); doc_props = dom_get_doc_props(intern->document); format = doc_props->formatoutput; bytes = htmlSaveFileFormat(file, docp, encoding, format); if (bytes == -1) { RETURN_FALSE; } RETURN_LONG(bytes); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,085
PHP_FUNCTION(dom_document_save_html) { zval *id, *nodep = NULL; xmlDoc *docp; xmlNode *node; xmlBufferPtr buf; dom_object *intern, *nodeobj; xmlChar *mem = NULL; int size = 0, format; dom_doc_propsptr doc_props; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|O!", &id, dom_document_class_entry, &nodep, dom_node_class_entry) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); doc_props = dom_get_doc_props(intern->document); format = doc_props->formatoutput; if (nodep != NULL) { /* Dump contents of Node */ DOM_GET_OBJ(node, nodep, xmlNodePtr, nodeobj); if (node->doc != docp) { php_dom_throw_error(WRONG_DOCUMENT_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } buf = xmlBufferCreate(); if (!buf) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch buffer"); RETURN_FALSE; } if (node->type == XML_DOCUMENT_FRAG_NODE) { int one_size; for (node = node->children; node; node = node->next) { one_size = htmlNodeDump(buf, docp, node); if (one_size >= 0) { size += one_size; } else { size = -1; break; } } } else { size = htmlNodeDump(buf, docp, node); } if (size >= 0) { mem = (xmlChar*) xmlBufferContent(buf); if (!mem) { RETVAL_FALSE; } else { RETVAL_STRINGL((const char*) mem, size, 1); } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error dumping HTML node"); RETVAL_FALSE; } xmlBufferFree(buf); } else { #if LIBXML_VERSION >= 20623 htmlDocDumpMemoryFormat(docp, &mem, &size, format); #else htmlDocDumpMemory(docp, &mem, &size); #endif if (!size) { RETVAL_FALSE; } else { RETVAL_STRINGL((const char*) mem, size, 1); } if (mem) xmlFree(mem); } }
Bypass
0
PHP_FUNCTION(dom_document_save_html) { zval *id, *nodep = NULL; xmlDoc *docp; xmlNode *node; xmlBufferPtr buf; dom_object *intern, *nodeobj; xmlChar *mem = NULL; int size = 0, format; dom_doc_propsptr doc_props; if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|O!", &id, dom_document_class_entry, &nodep, dom_node_class_entry) == FAILURE) { return; } DOM_GET_OBJ(docp, id, xmlDocPtr, intern); doc_props = dom_get_doc_props(intern->document); format = doc_props->formatoutput; if (nodep != NULL) { /* Dump contents of Node */ DOM_GET_OBJ(node, nodep, xmlNodePtr, nodeobj); if (node->doc != docp) { php_dom_throw_error(WRONG_DOCUMENT_ERR, dom_get_strict_error(intern->document) TSRMLS_CC); RETURN_FALSE; } buf = xmlBufferCreate(); if (!buf) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch buffer"); RETURN_FALSE; } if (node->type == XML_DOCUMENT_FRAG_NODE) { int one_size; for (node = node->children; node; node = node->next) { one_size = htmlNodeDump(buf, docp, node); if (one_size >= 0) { size += one_size; } else { size = -1; break; } } } else { size = htmlNodeDump(buf, docp, node); } if (size >= 0) { mem = (xmlChar*) xmlBufferContent(buf); if (!mem) { RETVAL_FALSE; } else { RETVAL_STRINGL((const char*) mem, size, 1); } } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error dumping HTML node"); RETVAL_FALSE; } xmlBufferFree(buf); } else { #if LIBXML_VERSION >= 20623 htmlDocDumpMemoryFormat(docp, &mem, &size, format); #else htmlDocDumpMemory(docp, &mem, &size); #endif if (!size) { RETVAL_FALSE; } else { RETVAL_STRINGL((const char*) mem, size, 1); } if (mem) xmlFree(mem); } }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,086
PHP_METHOD(domdocument, __construct) { zval *id; xmlDoc *docp = NULL, *olddoc; dom_object *intern; char *encoding, *version = NULL; int encoding_len = 0, version_len = 0, refcount; zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC); if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ss", &id, dom_document_class_entry, &version, &version_len, &encoding, &encoding_len) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } zend_restore_error_handling(&error_handling TSRMLS_CC); docp = xmlNewDoc(version); if (!docp) { php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC); RETURN_FALSE; } if (encoding_len > 0) { docp->encoding = (const xmlChar*)xmlStrdup(encoding); } intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); if (intern != NULL) { olddoc = (xmlDocPtr) dom_object_get_node(intern); if (olddoc != NULL) { php_libxml_decrement_node_ptr((php_libxml_node_object *) intern TSRMLS_CC); refcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); if (refcount != 0) { olddoc->_private = NULL; } } intern->document = NULL; if (php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp TSRMLS_CC) == -1) { RETURN_FALSE; } php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)docp, (void *)intern TSRMLS_CC); } }
Bypass
0
PHP_METHOD(domdocument, __construct) { zval *id; xmlDoc *docp = NULL, *olddoc; dom_object *intern; char *encoding, *version = NULL; int encoding_len = 0, version_len = 0, refcount; zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC); if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|ss", &id, dom_document_class_entry, &version, &version_len, &encoding, &encoding_len) == FAILURE) { zend_restore_error_handling(&error_handling TSRMLS_CC); return; } zend_restore_error_handling(&error_handling TSRMLS_CC); docp = xmlNewDoc(version); if (!docp) { php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC); RETURN_FALSE; } if (encoding_len > 0) { docp->encoding = (const xmlChar*)xmlStrdup(encoding); } intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC); if (intern != NULL) { olddoc = (xmlDocPtr) dom_object_get_node(intern); if (olddoc != NULL) { php_libxml_decrement_node_ptr((php_libxml_node_object *) intern TSRMLS_CC); refcount = php_libxml_decrement_doc_ref((php_libxml_node_object *)intern TSRMLS_CC); if (refcount != 0) { olddoc->_private = NULL; } } intern->document = NULL; if (php_libxml_increment_doc_ref((php_libxml_node_object *)intern, docp TSRMLS_CC) == -1) { RETURN_FALSE; } php_libxml_increment_node_ptr((php_libxml_node_object *)intern, (xmlNodePtr)docp, (void *)intern TSRMLS_CC); } }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,087
PHP_METHOD(domdocument, loadHTMLFile) { dom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); }
Bypass
0
PHP_METHOD(domdocument, loadHTMLFile) { dom_load_html(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,088
int dom_document_config_read(dom_object *obj, zval **retval TSRMLS_DC) { ALLOC_ZVAL(*retval); ZVAL_NULL(*retval); return SUCCESS; }
Bypass
0
int dom_document_config_read(dom_object *obj, zval **retval TSRMLS_DC) { ALLOC_ZVAL(*retval); ZVAL_NULL(*retval); return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,089
int dom_document_doctype_read(dom_object *obj, zval **retval TSRMLS_DC) { xmlDoc *docp; xmlDtdPtr dtdptr; int ret; docp = (xmlDocPtr) dom_object_get_node(obj); if (docp == NULL) { php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC); return FAILURE; } ALLOC_ZVAL(*retval); dtdptr = xmlGetIntSubset(docp); if (!dtdptr) { ZVAL_NULL(*retval); return SUCCESS; } if (NULL == (*retval = php_dom_create_object((xmlNodePtr) dtdptr, &ret, *retval, obj TSRMLS_CC))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); return FAILURE; } return SUCCESS; }
Bypass
0
int dom_document_doctype_read(dom_object *obj, zval **retval TSRMLS_DC) { xmlDoc *docp; xmlDtdPtr dtdptr; int ret; docp = (xmlDocPtr) dom_object_get_node(obj); if (docp == NULL) { php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC); return FAILURE; } ALLOC_ZVAL(*retval); dtdptr = xmlGetIntSubset(docp); if (!dtdptr) { ZVAL_NULL(*retval); return SUCCESS; } if (NULL == (*retval = php_dom_create_object((xmlNodePtr) dtdptr, &ret, *retval, obj TSRMLS_CC))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); return FAILURE; } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,090
int dom_document_document_element_read(dom_object *obj, zval **retval TSRMLS_DC) { xmlDoc *docp; xmlNode *root; int ret; docp = (xmlDocPtr) dom_object_get_node(obj); if (docp == NULL) { php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC); return FAILURE; } ALLOC_ZVAL(*retval); root = xmlDocGetRootElement(docp); if (!root) { ZVAL_NULL(*retval); return SUCCESS; } if (NULL == (*retval = php_dom_create_object(root, &ret, *retval, obj TSRMLS_CC))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); return FAILURE; } return SUCCESS; }
Bypass
0
int dom_document_document_element_read(dom_object *obj, zval **retval TSRMLS_DC) { xmlDoc *docp; xmlNode *root; int ret; docp = (xmlDocPtr) dom_object_get_node(obj); if (docp == NULL) { php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC); return FAILURE; } ALLOC_ZVAL(*retval); root = xmlDocGetRootElement(docp); if (!root) { ZVAL_NULL(*retval); return SUCCESS; } if (NULL == (*retval = php_dom_create_object(root, &ret, *retval, obj TSRMLS_CC))) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create required DOM object"); return FAILURE; } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,091
int dom_document_document_uri_read(dom_object *obj, zval **retval TSRMLS_DC) { xmlDoc *docp; char *url; docp = (xmlDocPtr) dom_object_get_node(obj); if (docp == NULL) { php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC); return FAILURE; } ALLOC_ZVAL(*retval); url = (char *) docp->URL; if (url != NULL) { ZVAL_STRING(*retval, url, 1); } else { ZVAL_NULL(*retval); } return SUCCESS; }
Bypass
0
int dom_document_document_uri_read(dom_object *obj, zval **retval TSRMLS_DC) { xmlDoc *docp; char *url; docp = (xmlDocPtr) dom_object_get_node(obj); if (docp == NULL) { php_dom_throw_error(INVALID_STATE_ERR, 0 TSRMLS_CC); return FAILURE; } ALLOC_ZVAL(*retval); url = (char *) docp->URL; if (url != NULL) { ZVAL_STRING(*retval, url, 1); } else { ZVAL_NULL(*retval); } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,092
int dom_document_format_output_read(dom_object *obj, zval **retval TSRMLS_DC) { dom_doc_propsptr doc_prop; ALLOC_ZVAL(*retval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); ZVAL_BOOL(*retval, doc_prop->formatoutput); } else { ZVAL_FALSE(*retval); } return SUCCESS; }
Bypass
0
int dom_document_format_output_read(dom_object *obj, zval **retval TSRMLS_DC) { dom_doc_propsptr doc_prop; ALLOC_ZVAL(*retval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); ZVAL_BOOL(*retval, doc_prop->formatoutput); } else { ZVAL_FALSE(*retval); } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,093
int dom_document_format_output_write(dom_object *obj, zval *newval TSRMLS_DC) { zval value_copy; dom_doc_propsptr doc_prop; if(Z_REFCOUNT_P(newval) > 1) { value_copy = *newval; zval_copy_ctor(&value_copy); newval = &value_copy; } convert_to_boolean(newval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); doc_prop->formatoutput = Z_LVAL_P(newval); } if (newval == &value_copy) { zval_dtor(newval); } return SUCCESS; }
Bypass
0
int dom_document_format_output_write(dom_object *obj, zval *newval TSRMLS_DC) { zval value_copy; dom_doc_propsptr doc_prop; if(Z_REFCOUNT_P(newval) > 1) { value_copy = *newval; zval_copy_ctor(&value_copy); newval = &value_copy; } convert_to_boolean(newval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); doc_prop->formatoutput = Z_LVAL_P(newval); } if (newval == &value_copy) { zval_dtor(newval); } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,094
int dom_document_implementation_read(dom_object *obj, zval **retval TSRMLS_DC) { ALLOC_ZVAL(*retval); php_dom_create_implementation(retval TSRMLS_CC); return SUCCESS; }
Bypass
0
int dom_document_implementation_read(dom_object *obj, zval **retval TSRMLS_DC) { ALLOC_ZVAL(*retval); php_dom_create_implementation(retval TSRMLS_CC); return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,095
int dom_document_preserve_whitespace_read(dom_object *obj, zval **retval TSRMLS_DC) { dom_doc_propsptr doc_prop; ALLOC_ZVAL(*retval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); ZVAL_BOOL(*retval, doc_prop->preservewhitespace); } else { ZVAL_FALSE(*retval); } return SUCCESS; }
Bypass
0
int dom_document_preserve_whitespace_read(dom_object *obj, zval **retval TSRMLS_DC) { dom_doc_propsptr doc_prop; ALLOC_ZVAL(*retval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); ZVAL_BOOL(*retval, doc_prop->preservewhitespace); } else { ZVAL_FALSE(*retval); } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,096
int dom_document_preserve_whitespace_write(dom_object *obj, zval *newval TSRMLS_DC) { zval value_copy; dom_doc_propsptr doc_prop; if(Z_REFCOUNT_P(newval) > 1) { value_copy = *newval; zval_copy_ctor(&value_copy); newval = &value_copy; } convert_to_boolean(newval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); doc_prop->preservewhitespace = Z_LVAL_P(newval); } if (newval == &value_copy) { zval_dtor(newval); } return SUCCESS; }
Bypass
0
int dom_document_preserve_whitespace_write(dom_object *obj, zval *newval TSRMLS_DC) { zval value_copy; dom_doc_propsptr doc_prop; if(Z_REFCOUNT_P(newval) > 1) { value_copy = *newval; zval_copy_ctor(&value_copy); newval = &value_copy; } convert_to_boolean(newval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); doc_prop->preservewhitespace = Z_LVAL_P(newval); } if (newval == &value_copy) { zval_dtor(newval); } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,097
int dom_document_recover_read(dom_object *obj, zval **retval TSRMLS_DC) { dom_doc_propsptr doc_prop; ALLOC_ZVAL(*retval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); ZVAL_BOOL(*retval, doc_prop->recover); } else { ZVAL_FALSE(*retval); } return SUCCESS; }
Bypass
0
int dom_document_recover_read(dom_object *obj, zval **retval TSRMLS_DC) { dom_doc_propsptr doc_prop; ALLOC_ZVAL(*retval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); ZVAL_BOOL(*retval, doc_prop->recover); } else { ZVAL_FALSE(*retval); } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,098
int dom_document_recover_write(dom_object *obj, zval *newval TSRMLS_DC) { zval value_copy; dom_doc_propsptr doc_prop; if(Z_REFCOUNT_P(newval) > 1) { value_copy = *newval; zval_copy_ctor(&value_copy); newval = &value_copy; } convert_to_boolean(newval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); doc_prop->recover = Z_LVAL_P(newval); } if (newval == &value_copy) { zval_dtor(newval); } return SUCCESS; }
Bypass
0
int dom_document_recover_write(dom_object *obj, zval *newval TSRMLS_DC) { zval value_copy; dom_doc_propsptr doc_prop; if(Z_REFCOUNT_P(newval) > 1) { value_copy = *newval; zval_copy_ctor(&value_copy); newval = &value_copy; } convert_to_boolean(newval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); doc_prop->recover = Z_LVAL_P(newval); } if (newval == &value_copy) { zval_dtor(newval); } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null
12,099
int dom_document_resolve_externals_read(dom_object *obj, zval **retval TSRMLS_DC) { dom_doc_propsptr doc_prop; ALLOC_ZVAL(*retval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); ZVAL_BOOL(*retval, doc_prop->resolveexternals); } else { ZVAL_FALSE(*retval); } return SUCCESS; }
Bypass
0
int dom_document_resolve_externals_read(dom_object *obj, zval **retval TSRMLS_DC) { dom_doc_propsptr doc_prop; ALLOC_ZVAL(*retval); if (obj->document) { doc_prop = dom_get_doc_props(obj->document); ZVAL_BOOL(*retval, doc_prop->resolveexternals); } else { ZVAL_FALSE(*retval); } return SUCCESS; }
@@ -1580,6 +1580,9 @@ static xmlDocPtr dom_document_parser(zval *id, int mode, char *source, int sourc xmlInitParser(); if (mode == DOM_LOAD_FILE) { + if (CHECK_NULL_PATH(source, source_len)) { + return NULL; + } char *file_dest = _dom_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (file_dest) { ctxt = xmlCreateFileParserCtxt(file_dest); @@ -2168,7 +2171,7 @@ static void dom_load_html(INTERNAL_FUNCTION_PARAMETERS, int mode) /* {{{ */ id = getThis(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|l", &source, &source_len, &options) == FAILURE) { return; }
CWE-254
null
null