idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
1,000
SplashPath *Splash::makeStrokePath(SplashPath *path, GBool flatten) { SplashPath *pathIn, *pathOut; SplashCoord w, d, dx, dy, wdx, wdy, dxNext, dyNext, wdxNext, wdyNext; SplashCoord crossprod, dotprod, miter, m; GBool first, last, closed; int subpathStart, next, i; int left0, left1, left2, right0, right1, right2, join0, join1, join2; int leftFirst, rightFirst, firstPt; if (flatten) { pathIn = flattenPath(path, state->matrix, state->flatness); if (state->lineDashLength > 0) { pathOut = makeDashedPath(pathIn); delete pathIn; pathIn = pathOut; } } else { pathIn = path; } subpathStart = 0; // make gcc happy closed = gFalse; // make gcc happy left0 = left1 = right0 = right1 = join0 = join1 = 0; // make gcc happy leftFirst = rightFirst = firstPt = 0; // make gcc happy pathOut = new SplashPath(); w = state->lineWidth; for (i = 0; i < pathIn->length - 1; ++i) { if (pathIn->flags[i] & splashPathLast) { continue; } if ((first = pathIn->flags[i] & splashPathFirst)) { subpathStart = i; closed = pathIn->flags[i] & splashPathClosed; } last = pathIn->flags[i+1] & splashPathLast; d = splashDist(pathIn->pts[i].x, pathIn->pts[i].y, pathIn->pts[i+1].x, pathIn->pts[i+1].y); if (d == 0) { dx = 0; dy = 1; } else { d = (SplashCoord)1 / d; dx = d * (pathIn->pts[i+1].x - pathIn->pts[i].x); dy = d * (pathIn->pts[i+1].y - pathIn->pts[i].y); } wdx = (SplashCoord)0.5 * w * dx; wdy = (SplashCoord)0.5 * w * dy; next = last ? subpathStart + 1 : i + 2; d = splashDist(pathIn->pts[i+1].x, pathIn->pts[i+1].y, pathIn->pts[next].x, pathIn->pts[next].y); if (d == 0) { dxNext = 0; dyNext = 1; } else { d = (SplashCoord)1 / d; dxNext = d * (pathIn->pts[next].x - pathIn->pts[i+1].x); dyNext = d * (pathIn->pts[next].y - pathIn->pts[i+1].y); } wdxNext = (SplashCoord)0.5 * w * dxNext; wdyNext = (SplashCoord)0.5 * w * dyNext; pathOut->moveTo(pathIn->pts[i].x - wdy, pathIn->pts[i].y + wdx); if (i == subpathStart) { firstPt = pathOut->length - 1; } if (first && !closed) { switch (state->lineCap) { case splashLineCapButt: pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; case splashLineCapRound: pathOut->curveTo(pathIn->pts[i].x - wdy - bezierCircle * wdx, pathIn->pts[i].y + wdx - bezierCircle * wdy, pathIn->pts[i].x - wdx - bezierCircle * wdy, pathIn->pts[i].y - wdy + bezierCircle * wdx, pathIn->pts[i].x - wdx, pathIn->pts[i].y - wdy); pathOut->curveTo(pathIn->pts[i].x - wdx + bezierCircle * wdy, pathIn->pts[i].y - wdy - bezierCircle * wdx, pathIn->pts[i].x + wdy - bezierCircle * wdx, pathIn->pts[i].y - wdx - bezierCircle * wdy, pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; case splashLineCapProjecting: pathOut->lineTo(pathIn->pts[i].x - wdx - wdy, pathIn->pts[i].y + wdx - wdy); pathOut->lineTo(pathIn->pts[i].x - wdx + wdy, pathIn->pts[i].y - wdx - wdy); pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; } } else { pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); } left2 = pathOut->length - 1; pathOut->lineTo(pathIn->pts[i+1].x + wdy, pathIn->pts[i+1].y - wdx); if (last && !closed) { switch (state->lineCap) { case splashLineCapButt: pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; case splashLineCapRound: pathOut->curveTo(pathIn->pts[i+1].x + wdy + bezierCircle * wdx, pathIn->pts[i+1].y - wdx + bezierCircle * wdy, pathIn->pts[i+1].x + wdx + bezierCircle * wdy, pathIn->pts[i+1].y + wdy - bezierCircle * wdx, pathIn->pts[i+1].x + wdx, pathIn->pts[i+1].y + wdy); pathOut->curveTo(pathIn->pts[i+1].x + wdx - bezierCircle * wdy, pathIn->pts[i+1].y + wdy + bezierCircle * wdx, pathIn->pts[i+1].x - wdy + bezierCircle * wdx, pathIn->pts[i+1].y + wdx + bezierCircle * wdy, pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; case splashLineCapProjecting: pathOut->lineTo(pathIn->pts[i+1].x + wdy + wdx, pathIn->pts[i+1].y - wdx + wdy); pathOut->lineTo(pathIn->pts[i+1].x - wdy + wdx, pathIn->pts[i+1].y + wdx + wdy); pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; } } else { pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } right2 = pathOut->length - 1; pathOut->close(); join2 = pathOut->length; if (!last || closed) { crossprod = dx * dyNext - dy * dxNext; dotprod = -(dx * dxNext + dy * dyNext); if (dotprod > 0.99999) { miter = (state->miterLimit + 1) * (state->miterLimit + 1); m = 0; } else { miter = (SplashCoord)2 / ((SplashCoord)1 - dotprod); if (miter < 1) { miter = 1; } m = splashSqrt(miter - 1); } if (state->lineJoin == splashLineJoinRound) { pathOut->moveTo(pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y); pathOut->curveTo(pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y + bezierCircle2 * w, pathIn->pts[i+1].x + bezierCircle2 * w, pathIn->pts[i+1].y + (SplashCoord)0.5 * w, pathIn->pts[i+1].x, pathIn->pts[i+1].y + (SplashCoord)0.5 * w); pathOut->curveTo(pathIn->pts[i+1].x - bezierCircle2 * w, pathIn->pts[i+1].y + (SplashCoord)0.5 * w, pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y + bezierCircle2 * w, pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y); pathOut->curveTo(pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y - bezierCircle2 * w, pathIn->pts[i+1].x - bezierCircle2 * w, pathIn->pts[i+1].y - (SplashCoord)0.5 * w, pathIn->pts[i+1].x, pathIn->pts[i+1].y - (SplashCoord)0.5 * w); pathOut->curveTo(pathIn->pts[i+1].x + bezierCircle2 * w, pathIn->pts[i+1].y - (SplashCoord)0.5 * w, pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y - bezierCircle2 * w, pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y); } else { pathOut->moveTo(pathIn->pts[i+1].x, pathIn->pts[i+1].y); if (crossprod < 0) { pathOut->lineTo(pathIn->pts[i+1].x - wdyNext, pathIn->pts[i+1].y + wdxNext); if (state->lineJoin == splashLineJoinMiter && splashSqrt(miter) <= state->miterLimit) { pathOut->lineTo(pathIn->pts[i+1].x - wdy + wdx * m, pathIn->pts[i+1].y + wdx + wdy * m); pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } else { pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } } else { pathOut->lineTo(pathIn->pts[i+1].x + wdy, pathIn->pts[i+1].y - wdx); if (state->lineJoin == splashLineJoinMiter && splashSqrt(miter) <= state->miterLimit) { pathOut->lineTo(pathIn->pts[i+1].x + wdy + wdx * m, pathIn->pts[i+1].y - wdx + wdy * m); pathOut->lineTo(pathIn->pts[i+1].x + wdyNext, pathIn->pts[i+1].y - wdxNext); } else { pathOut->lineTo(pathIn->pts[i+1].x + wdyNext, pathIn->pts[i+1].y - wdxNext); } } } pathOut->close(); } if (state->strokeAdjust) { if (i >= subpathStart + 1) { if (i >= subpathStart + 2) { pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0); pathOut->addStrokeAdjustHint(left1, right1, join0, left2); } else { pathOut->addStrokeAdjustHint(left1, right1, firstPt, left2); } pathOut->addStrokeAdjustHint(left1, right1, right2 + 1, right2 + 1); } left0 = left1; left1 = left2; right0 = right1; right1 = right2; join0 = join1; join1 = join2; if (i == subpathStart) { leftFirst = left2; rightFirst = right2; } if (last) { if (i >= subpathStart + 2) { pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0); pathOut->addStrokeAdjustHint(left1, right1, join0, pathOut->length - 1); } else { pathOut->addStrokeAdjustHint(left1, right1, firstPt, pathOut->length - 1); } if (closed) { pathOut->addStrokeAdjustHint(left1, right1, firstPt, leftFirst); pathOut->addStrokeAdjustHint(left1, right1, rightFirst + 1, rightFirst + 1); pathOut->addStrokeAdjustHint(leftFirst, rightFirst, left1 + 1, right1); pathOut->addStrokeAdjustHint(leftFirst, rightFirst, join1, pathOut->length - 1); } } } } if (pathIn != path) { delete pathIn; } return pathOut; }
DoS Exec Code Overflow
0
SplashPath *Splash::makeStrokePath(SplashPath *path, GBool flatten) { SplashPath *pathIn, *pathOut; SplashCoord w, d, dx, dy, wdx, wdy, dxNext, dyNext, wdxNext, wdyNext; SplashCoord crossprod, dotprod, miter, m; GBool first, last, closed; int subpathStart, next, i; int left0, left1, left2, right0, right1, right2, join0, join1, join2; int leftFirst, rightFirst, firstPt; if (flatten) { pathIn = flattenPath(path, state->matrix, state->flatness); if (state->lineDashLength > 0) { pathOut = makeDashedPath(pathIn); delete pathIn; pathIn = pathOut; } } else { pathIn = path; } subpathStart = 0; // make gcc happy closed = gFalse; // make gcc happy left0 = left1 = right0 = right1 = join0 = join1 = 0; // make gcc happy leftFirst = rightFirst = firstPt = 0; // make gcc happy pathOut = new SplashPath(); w = state->lineWidth; for (i = 0; i < pathIn->length - 1; ++i) { if (pathIn->flags[i] & splashPathLast) { continue; } if ((first = pathIn->flags[i] & splashPathFirst)) { subpathStart = i; closed = pathIn->flags[i] & splashPathClosed; } last = pathIn->flags[i+1] & splashPathLast; d = splashDist(pathIn->pts[i].x, pathIn->pts[i].y, pathIn->pts[i+1].x, pathIn->pts[i+1].y); if (d == 0) { dx = 0; dy = 1; } else { d = (SplashCoord)1 / d; dx = d * (pathIn->pts[i+1].x - pathIn->pts[i].x); dy = d * (pathIn->pts[i+1].y - pathIn->pts[i].y); } wdx = (SplashCoord)0.5 * w * dx; wdy = (SplashCoord)0.5 * w * dy; next = last ? subpathStart + 1 : i + 2; d = splashDist(pathIn->pts[i+1].x, pathIn->pts[i+1].y, pathIn->pts[next].x, pathIn->pts[next].y); if (d == 0) { dxNext = 0; dyNext = 1; } else { d = (SplashCoord)1 / d; dxNext = d * (pathIn->pts[next].x - pathIn->pts[i+1].x); dyNext = d * (pathIn->pts[next].y - pathIn->pts[i+1].y); } wdxNext = (SplashCoord)0.5 * w * dxNext; wdyNext = (SplashCoord)0.5 * w * dyNext; pathOut->moveTo(pathIn->pts[i].x - wdy, pathIn->pts[i].y + wdx); if (i == subpathStart) { firstPt = pathOut->length - 1; } if (first && !closed) { switch (state->lineCap) { case splashLineCapButt: pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; case splashLineCapRound: pathOut->curveTo(pathIn->pts[i].x - wdy - bezierCircle * wdx, pathIn->pts[i].y + wdx - bezierCircle * wdy, pathIn->pts[i].x - wdx - bezierCircle * wdy, pathIn->pts[i].y - wdy + bezierCircle * wdx, pathIn->pts[i].x - wdx, pathIn->pts[i].y - wdy); pathOut->curveTo(pathIn->pts[i].x - wdx + bezierCircle * wdy, pathIn->pts[i].y - wdy - bezierCircle * wdx, pathIn->pts[i].x + wdy - bezierCircle * wdx, pathIn->pts[i].y - wdx - bezierCircle * wdy, pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; case splashLineCapProjecting: pathOut->lineTo(pathIn->pts[i].x - wdx - wdy, pathIn->pts[i].y + wdx - wdy); pathOut->lineTo(pathIn->pts[i].x - wdx + wdy, pathIn->pts[i].y - wdx - wdy); pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); break; } } else { pathOut->lineTo(pathIn->pts[i].x + wdy, pathIn->pts[i].y - wdx); } left2 = pathOut->length - 1; pathOut->lineTo(pathIn->pts[i+1].x + wdy, pathIn->pts[i+1].y - wdx); if (last && !closed) { switch (state->lineCap) { case splashLineCapButt: pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; case splashLineCapRound: pathOut->curveTo(pathIn->pts[i+1].x + wdy + bezierCircle * wdx, pathIn->pts[i+1].y - wdx + bezierCircle * wdy, pathIn->pts[i+1].x + wdx + bezierCircle * wdy, pathIn->pts[i+1].y + wdy - bezierCircle * wdx, pathIn->pts[i+1].x + wdx, pathIn->pts[i+1].y + wdy); pathOut->curveTo(pathIn->pts[i+1].x + wdx - bezierCircle * wdy, pathIn->pts[i+1].y + wdy + bezierCircle * wdx, pathIn->pts[i+1].x - wdy + bezierCircle * wdx, pathIn->pts[i+1].y + wdx + bezierCircle * wdy, pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; case splashLineCapProjecting: pathOut->lineTo(pathIn->pts[i+1].x + wdy + wdx, pathIn->pts[i+1].y - wdx + wdy); pathOut->lineTo(pathIn->pts[i+1].x - wdy + wdx, pathIn->pts[i+1].y + wdx + wdy); pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); break; } } else { pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } right2 = pathOut->length - 1; pathOut->close(); join2 = pathOut->length; if (!last || closed) { crossprod = dx * dyNext - dy * dxNext; dotprod = -(dx * dxNext + dy * dyNext); if (dotprod > 0.99999) { miter = (state->miterLimit + 1) * (state->miterLimit + 1); m = 0; } else { miter = (SplashCoord)2 / ((SplashCoord)1 - dotprod); if (miter < 1) { miter = 1; } m = splashSqrt(miter - 1); } if (state->lineJoin == splashLineJoinRound) { pathOut->moveTo(pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y); pathOut->curveTo(pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y + bezierCircle2 * w, pathIn->pts[i+1].x + bezierCircle2 * w, pathIn->pts[i+1].y + (SplashCoord)0.5 * w, pathIn->pts[i+1].x, pathIn->pts[i+1].y + (SplashCoord)0.5 * w); pathOut->curveTo(pathIn->pts[i+1].x - bezierCircle2 * w, pathIn->pts[i+1].y + (SplashCoord)0.5 * w, pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y + bezierCircle2 * w, pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y); pathOut->curveTo(pathIn->pts[i+1].x - (SplashCoord)0.5 * w, pathIn->pts[i+1].y - bezierCircle2 * w, pathIn->pts[i+1].x - bezierCircle2 * w, pathIn->pts[i+1].y - (SplashCoord)0.5 * w, pathIn->pts[i+1].x, pathIn->pts[i+1].y - (SplashCoord)0.5 * w); pathOut->curveTo(pathIn->pts[i+1].x + bezierCircle2 * w, pathIn->pts[i+1].y - (SplashCoord)0.5 * w, pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y - bezierCircle2 * w, pathIn->pts[i+1].x + (SplashCoord)0.5 * w, pathIn->pts[i+1].y); } else { pathOut->moveTo(pathIn->pts[i+1].x, pathIn->pts[i+1].y); if (crossprod < 0) { pathOut->lineTo(pathIn->pts[i+1].x - wdyNext, pathIn->pts[i+1].y + wdxNext); if (state->lineJoin == splashLineJoinMiter && splashSqrt(miter) <= state->miterLimit) { pathOut->lineTo(pathIn->pts[i+1].x - wdy + wdx * m, pathIn->pts[i+1].y + wdx + wdy * m); pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } else { pathOut->lineTo(pathIn->pts[i+1].x - wdy, pathIn->pts[i+1].y + wdx); } } else { pathOut->lineTo(pathIn->pts[i+1].x + wdy, pathIn->pts[i+1].y - wdx); if (state->lineJoin == splashLineJoinMiter && splashSqrt(miter) <= state->miterLimit) { pathOut->lineTo(pathIn->pts[i+1].x + wdy + wdx * m, pathIn->pts[i+1].y - wdx + wdy * m); pathOut->lineTo(pathIn->pts[i+1].x + wdyNext, pathIn->pts[i+1].y - wdxNext); } else { pathOut->lineTo(pathIn->pts[i+1].x + wdyNext, pathIn->pts[i+1].y - wdxNext); } } } pathOut->close(); } if (state->strokeAdjust) { if (i >= subpathStart + 1) { if (i >= subpathStart + 2) { pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0); pathOut->addStrokeAdjustHint(left1, right1, join0, left2); } else { pathOut->addStrokeAdjustHint(left1, right1, firstPt, left2); } pathOut->addStrokeAdjustHint(left1, right1, right2 + 1, right2 + 1); } left0 = left1; left1 = left2; right0 = right1; right1 = right2; join0 = join1; join1 = join2; if (i == subpathStart) { leftFirst = left2; rightFirst = right2; } if (last) { if (i >= subpathStart + 2) { pathOut->addStrokeAdjustHint(left1, right1, left0 + 1, right0); pathOut->addStrokeAdjustHint(left1, right1, join0, pathOut->length - 1); } else { pathOut->addStrokeAdjustHint(left1, right1, firstPt, pathOut->length - 1); } if (closed) { pathOut->addStrokeAdjustHint(left1, right1, firstPt, leftFirst); pathOut->addStrokeAdjustHint(left1, right1, rightFirst + 1, rightFirst + 1); pathOut->addStrokeAdjustHint(leftFirst, rightFirst, left1 + 1, right1); pathOut->addStrokeAdjustHint(leftFirst, rightFirst, join1, pathOut->length - 1); } } } } if (pathIn != path) { delete pathIn; } return pathOut; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,001
inline void Splash::pipeIncX(SplashPipe *pipe) { ++pipe->x; if (state->softMask) { ++pipe->softMaskPtr; } switch (bitmap->mode) { case splashModeMono1: if (!(pipe->destColorMask >>= 1)) { pipe->destColorMask = 0x80; ++pipe->destColorPtr; } break; case splashModeMono8: ++pipe->destColorPtr; break; case splashModeRGB8: case splashModeBGR8: pipe->destColorPtr += 3; break; case splashModeXBGR8: pipe->destColorPtr += 4; break; #if SPLASH_CMYK case splashModeCMYK8: pipe->destColorPtr += 4; break; #endif } if (pipe->destAlphaPtr) { ++pipe->destAlphaPtr; } if (pipe->alpha0Ptr) { ++pipe->alpha0Ptr; } }
DoS Exec Code Overflow
0
inline void Splash::pipeIncX(SplashPipe *pipe) { ++pipe->x; if (state->softMask) { ++pipe->softMaskPtr; } switch (bitmap->mode) { case splashModeMono1: if (!(pipe->destColorMask >>= 1)) { pipe->destColorMask = 0x80; ++pipe->destColorPtr; } break; case splashModeMono8: ++pipe->destColorPtr; break; case splashModeRGB8: case splashModeBGR8: pipe->destColorPtr += 3; break; case splashModeXBGR8: pipe->destColorPtr += 4; break; #if SPLASH_CMYK case splashModeCMYK8: pipe->destColorPtr += 4; break; #endif } if (pipe->destAlphaPtr) { ++pipe->destAlphaPtr; } if (pipe->alpha0Ptr) { ++pipe->alpha0Ptr; } }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,002
inline void Splash::pipeInit(SplashPipe *pipe, int x, int y, SplashPattern *pattern, SplashColorPtr cSrc, SplashCoord aInput, GBool usesShape, GBool nonIsolatedGroup) { pipeSetXY(pipe, x, y); pipe->pattern = NULL; if (pattern) { if (pattern->isStatic()) { pattern->getColor(x, y, pipe->cSrcVal); } else { pipe->pattern = pattern; } pipe->cSrc = pipe->cSrcVal; } else { pipe->cSrc = cSrc; } pipe->aInput = aInput; if (!state->softMask) { if (usesShape) { pipe->aInput *= 255; } else { pipe->aSrc = (Guchar)splashRound(pipe->aInput * 255); } } pipe->usesShape = usesShape; if (aInput == 1 && !state->softMask && !usesShape && !state->inNonIsolatedGroup) { pipe->noTransparency = gTrue; } else { pipe->noTransparency = gFalse; } if (pipe->noTransparency) { pipe->resultColorCtrl = pipeResultColorNoAlphaBlend[bitmap->mode]; } else if (!state->blendFunc) { pipe->resultColorCtrl = pipeResultColorAlphaNoBlend[bitmap->mode]; } else { pipe->resultColorCtrl = pipeResultColorAlphaBlend[bitmap->mode]; } if (nonIsolatedGroup) { pipe->nonIsolatedGroup = splashColorModeNComps[bitmap->mode]; } else { pipe->nonIsolatedGroup = 0; } }
DoS Exec Code Overflow
0
inline void Splash::pipeInit(SplashPipe *pipe, int x, int y, SplashPattern *pattern, SplashColorPtr cSrc, SplashCoord aInput, GBool usesShape, GBool nonIsolatedGroup) { pipeSetXY(pipe, x, y); pipe->pattern = NULL; if (pattern) { if (pattern->isStatic()) { pattern->getColor(x, y, pipe->cSrcVal); } else { pipe->pattern = pattern; } pipe->cSrc = pipe->cSrcVal; } else { pipe->cSrc = cSrc; } pipe->aInput = aInput; if (!state->softMask) { if (usesShape) { pipe->aInput *= 255; } else { pipe->aSrc = (Guchar)splashRound(pipe->aInput * 255); } } pipe->usesShape = usesShape; if (aInput == 1 && !state->softMask && !usesShape && !state->inNonIsolatedGroup) { pipe->noTransparency = gTrue; } else { pipe->noTransparency = gFalse; } if (pipe->noTransparency) { pipe->resultColorCtrl = pipeResultColorNoAlphaBlend[bitmap->mode]; } else if (!state->blendFunc) { pipe->resultColorCtrl = pipeResultColorAlphaNoBlend[bitmap->mode]; } else { pipe->resultColorCtrl = pipeResultColorAlphaBlend[bitmap->mode]; } if (nonIsolatedGroup) { pipe->nonIsolatedGroup = splashColorModeNComps[bitmap->mode]; } else { pipe->nonIsolatedGroup = 0; } }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,003
inline void Splash::pipeRun(SplashPipe *pipe) { Guchar aSrc, aDest, alpha2, alpha0, aResult; SplashColor cDest, cBlend; Guchar cResult0, cResult1, cResult2, cResult3; if (pipe->pattern) { pipe->pattern->getColor(pipe->x, pipe->y, pipe->cSrcVal); } if (pipe->noTransparency && !state->blendFunc) { switch (bitmap->mode) { case splashModeMono1: cResult0 = pipe->cSrc[0]; if (state->screen->test(pipe->x, pipe->y, cResult0)) { *pipe->destColorPtr |= pipe->destColorMask; } else { *pipe->destColorPtr &= ~pipe->destColorMask; } if (!(pipe->destColorMask >>= 1)) { pipe->destColorMask = 0x80; ++pipe->destColorPtr; } break; case splashModeMono8: *pipe->destColorPtr++ = pipe->cSrc[0]; break; case splashModeRGB8: *pipe->destColorPtr++ = pipe->cSrc[0]; *pipe->destColorPtr++ = pipe->cSrc[1]; *pipe->destColorPtr++ = pipe->cSrc[2]; break; case splashModeXBGR8: *pipe->destColorPtr++ = pipe->cSrc[2]; *pipe->destColorPtr++ = pipe->cSrc[1]; *pipe->destColorPtr++ = pipe->cSrc[0]; *pipe->destColorPtr++ = 255; break; case splashModeBGR8: *pipe->destColorPtr++ = pipe->cSrc[2]; *pipe->destColorPtr++ = pipe->cSrc[1]; *pipe->destColorPtr++ = pipe->cSrc[0]; break; #if SPLASH_CMYK case splashModeCMYK8: *pipe->destColorPtr++ = pipe->cSrc[0]; *pipe->destColorPtr++ = pipe->cSrc[1]; *pipe->destColorPtr++ = pipe->cSrc[2]; *pipe->destColorPtr++ = pipe->cSrc[3]; break; #endif } if (pipe->destAlphaPtr) { *pipe->destAlphaPtr++ = 255; } } else { switch (bitmap->mode) { case splashModeMono1: cDest[0] = (*pipe->destColorPtr & pipe->destColorMask) ? 0xff : 0x00; break; case splashModeMono8: cDest[0] = *pipe->destColorPtr; break; case splashModeRGB8: cDest[0] = pipe->destColorPtr[0]; cDest[1] = pipe->destColorPtr[1]; cDest[2] = pipe->destColorPtr[2]; break; case splashModeXBGR8: cDest[0] = pipe->destColorPtr[2]; cDest[1] = pipe->destColorPtr[1]; cDest[2] = pipe->destColorPtr[0]; cDest[3] = 255; break; case splashModeBGR8: cDest[0] = pipe->destColorPtr[2]; cDest[1] = pipe->destColorPtr[1]; cDest[2] = pipe->destColorPtr[0]; break; #if SPLASH_CMYK case splashModeCMYK8: cDest[0] = pipe->destColorPtr[0]; cDest[1] = pipe->destColorPtr[1]; cDest[2] = pipe->destColorPtr[2]; cDest[3] = pipe->destColorPtr[3]; break; #endif } if (pipe->destAlphaPtr) { aDest = *pipe->destAlphaPtr; } else { aDest = 0xff; } if (state->blendFunc) { (*state->blendFunc)(pipe->cSrc, cDest, cBlend, bitmap->mode); } if (state->softMask) { if (pipe->usesShape) { aSrc = (Guchar)splashRound(pipe->aInput * *pipe->softMaskPtr++ * pipe->shape); } else { aSrc = (Guchar)splashRound(pipe->aInput * *pipe->softMaskPtr++); } } else if (pipe->usesShape) { aSrc = (Guchar)splashRound(pipe->aInput * pipe->shape); } else { aSrc = pipe->aSrc; } if (pipe->noTransparency) { alpha2 = aResult = 255; } else { aResult = aSrc + aDest - div255(aSrc * aDest); if (pipe->alpha0Ptr) { alpha0 = *pipe->alpha0Ptr++; alpha2 = aResult + alpha0 - div255(aResult * alpha0); } else { alpha2 = aResult; } } cResult0 = cResult1 = cResult2 = cResult3 = 0; // make gcc happy switch (pipe->resultColorCtrl) { #if SPLASH_CMYK case splashPipeResultColorNoAlphaBlendCMYK: cResult3 = div255((255 - aDest) * pipe->cSrc[3] + aDest * cBlend[3]); #endif case splashPipeResultColorNoAlphaBlendRGB: cResult2 = div255((255 - aDest) * pipe->cSrc[2] + aDest * cBlend[2]); cResult1 = div255((255 - aDest) * pipe->cSrc[1] + aDest * cBlend[1]); case splashPipeResultColorNoAlphaBlendMono: cResult0 = div255((255 - aDest) * pipe->cSrc[0] + aDest * cBlend[0]); break; case splashPipeResultColorAlphaNoBlendMono: if (alpha2 == 0) { cResult0 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * pipe->cSrc[0]) / alpha2); } break; case splashPipeResultColorAlphaNoBlendRGB: if (alpha2 == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * pipe->cSrc[0]) / alpha2); cResult1 = (Guchar)(((alpha2 - aSrc) * cDest[1] + aSrc * pipe->cSrc[1]) / alpha2); cResult2 = (Guchar)(((alpha2 - aSrc) * cDest[2] + aSrc * pipe->cSrc[2]) / alpha2); } break; #if SPLASH_CMYK case splashPipeResultColorAlphaNoBlendCMYK: if (alpha2 == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; cResult3 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * pipe->cSrc[0]) / alpha2); cResult1 = (Guchar)(((alpha2 - aSrc) * cDest[1] + aSrc * pipe->cSrc[1]) / alpha2); cResult2 = (Guchar)(((alpha2 - aSrc) * cDest[2] + aSrc * pipe->cSrc[2]) / alpha2); cResult3 = (Guchar)(((alpha2 - aSrc) * cDest[3] + aSrc * pipe->cSrc[3]) / alpha2); } break; #endif case splashPipeResultColorAlphaBlendMono: if (alpha2 == 0) { cResult0 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * ((255 - aDest) * pipe->cSrc[0] + aDest * cBlend[0]) / 255) / alpha2); } break; case splashPipeResultColorAlphaBlendRGB: if (alpha2 == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * ((255 - aDest) * pipe->cSrc[0] + aDest * cBlend[0]) / 255) / alpha2); cResult1 = (Guchar)(((alpha2 - aSrc) * cDest[1] + aSrc * ((255 - aDest) * pipe->cSrc[1] + aDest * cBlend[1]) / 255) / alpha2); cResult2 = (Guchar)(((alpha2 - aSrc) * cDest[2] + aSrc * ((255 - aDest) * pipe->cSrc[2] + aDest * cBlend[2]) / 255) / alpha2); } break; #if SPLASH_CMYK case splashPipeResultColorAlphaBlendCMYK: if (alpha2 == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; cResult3 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * ((255 - aDest) * pipe->cSrc[0] + aDest * cBlend[0]) / 255) / alpha2); cResult1 = (Guchar)(((alpha2 - aSrc) * cDest[1] + aSrc * ((255 - aDest) * pipe->cSrc[1] + aDest * cBlend[1]) / 255) / alpha2); cResult2 = (Guchar)(((alpha2 - aSrc) * cDest[2] + aSrc * ((255 - aDest) * pipe->cSrc[2] + aDest * cBlend[2]) / 255) / alpha2); cResult3 = (Guchar)(((alpha2 - aSrc) * cDest[3] + aSrc * ((255 - aDest) * pipe->cSrc[3] + aDest * cBlend[3]) / 255) / alpha2); } break; #endif } if (aResult != 0) { switch (pipe->nonIsolatedGroup) { #if SPLASH_CMYK case 4: cResult3 += (cResult3 - cDest[3]) * aDest * (255 - aResult) / (255 * aResult); #endif case 3: cResult2 += (cResult2 - cDest[2]) * aDest * (255 - aResult) / (255 * aResult); cResult1 += (cResult1 - cDest[1]) * aDest * (255 - aResult) / (255 * aResult); case 1: cResult0 += (cResult0 - cDest[0]) * aDest * (255 - aResult) / (255 * aResult); case 0: break; } } switch (bitmap->mode) { case splashModeMono1: if (state->screen->test(pipe->x, pipe->y, cResult0)) { *pipe->destColorPtr |= pipe->destColorMask; } else { *pipe->destColorPtr &= ~pipe->destColorMask; } if (!(pipe->destColorMask >>= 1)) { pipe->destColorMask = 0x80; ++pipe->destColorPtr; } break; case splashModeMono8: *pipe->destColorPtr++ = cResult0; break; case splashModeRGB8: *pipe->destColorPtr++ = cResult0; *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult2; break; case splashModeXBGR8: *pipe->destColorPtr++ = cResult2; *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult0; *pipe->destColorPtr++ = 255; break; case splashModeBGR8: *pipe->destColorPtr++ = cResult2; *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult0; break; #if SPLASH_CMYK case splashModeCMYK8: *pipe->destColorPtr++ = cResult0; *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult2; *pipe->destColorPtr++ = cResult3; break; #endif } if (pipe->destAlphaPtr) { *pipe->destAlphaPtr++ = aResult; } } ++pipe->x; }
DoS Exec Code Overflow
0
inline void Splash::pipeRun(SplashPipe *pipe) { Guchar aSrc, aDest, alpha2, alpha0, aResult; SplashColor cDest, cBlend; Guchar cResult0, cResult1, cResult2, cResult3; if (pipe->pattern) { pipe->pattern->getColor(pipe->x, pipe->y, pipe->cSrcVal); } if (pipe->noTransparency && !state->blendFunc) { switch (bitmap->mode) { case splashModeMono1: cResult0 = pipe->cSrc[0]; if (state->screen->test(pipe->x, pipe->y, cResult0)) { *pipe->destColorPtr |= pipe->destColorMask; } else { *pipe->destColorPtr &= ~pipe->destColorMask; } if (!(pipe->destColorMask >>= 1)) { pipe->destColorMask = 0x80; ++pipe->destColorPtr; } break; case splashModeMono8: *pipe->destColorPtr++ = pipe->cSrc[0]; break; case splashModeRGB8: *pipe->destColorPtr++ = pipe->cSrc[0]; *pipe->destColorPtr++ = pipe->cSrc[1]; *pipe->destColorPtr++ = pipe->cSrc[2]; break; case splashModeXBGR8: *pipe->destColorPtr++ = pipe->cSrc[2]; *pipe->destColorPtr++ = pipe->cSrc[1]; *pipe->destColorPtr++ = pipe->cSrc[0]; *pipe->destColorPtr++ = 255; break; case splashModeBGR8: *pipe->destColorPtr++ = pipe->cSrc[2]; *pipe->destColorPtr++ = pipe->cSrc[1]; *pipe->destColorPtr++ = pipe->cSrc[0]; break; #if SPLASH_CMYK case splashModeCMYK8: *pipe->destColorPtr++ = pipe->cSrc[0]; *pipe->destColorPtr++ = pipe->cSrc[1]; *pipe->destColorPtr++ = pipe->cSrc[2]; *pipe->destColorPtr++ = pipe->cSrc[3]; break; #endif } if (pipe->destAlphaPtr) { *pipe->destAlphaPtr++ = 255; } } else { switch (bitmap->mode) { case splashModeMono1: cDest[0] = (*pipe->destColorPtr & pipe->destColorMask) ? 0xff : 0x00; break; case splashModeMono8: cDest[0] = *pipe->destColorPtr; break; case splashModeRGB8: cDest[0] = pipe->destColorPtr[0]; cDest[1] = pipe->destColorPtr[1]; cDest[2] = pipe->destColorPtr[2]; break; case splashModeXBGR8: cDest[0] = pipe->destColorPtr[2]; cDest[1] = pipe->destColorPtr[1]; cDest[2] = pipe->destColorPtr[0]; cDest[3] = 255; break; case splashModeBGR8: cDest[0] = pipe->destColorPtr[2]; cDest[1] = pipe->destColorPtr[1]; cDest[2] = pipe->destColorPtr[0]; break; #if SPLASH_CMYK case splashModeCMYK8: cDest[0] = pipe->destColorPtr[0]; cDest[1] = pipe->destColorPtr[1]; cDest[2] = pipe->destColorPtr[2]; cDest[3] = pipe->destColorPtr[3]; break; #endif } if (pipe->destAlphaPtr) { aDest = *pipe->destAlphaPtr; } else { aDest = 0xff; } if (state->blendFunc) { (*state->blendFunc)(pipe->cSrc, cDest, cBlend, bitmap->mode); } if (state->softMask) { if (pipe->usesShape) { aSrc = (Guchar)splashRound(pipe->aInput * *pipe->softMaskPtr++ * pipe->shape); } else { aSrc = (Guchar)splashRound(pipe->aInput * *pipe->softMaskPtr++); } } else if (pipe->usesShape) { aSrc = (Guchar)splashRound(pipe->aInput * pipe->shape); } else { aSrc = pipe->aSrc; } if (pipe->noTransparency) { alpha2 = aResult = 255; } else { aResult = aSrc + aDest - div255(aSrc * aDest); if (pipe->alpha0Ptr) { alpha0 = *pipe->alpha0Ptr++; alpha2 = aResult + alpha0 - div255(aResult * alpha0); } else { alpha2 = aResult; } } cResult0 = cResult1 = cResult2 = cResult3 = 0; // make gcc happy switch (pipe->resultColorCtrl) { #if SPLASH_CMYK case splashPipeResultColorNoAlphaBlendCMYK: cResult3 = div255((255 - aDest) * pipe->cSrc[3] + aDest * cBlend[3]); #endif case splashPipeResultColorNoAlphaBlendRGB: cResult2 = div255((255 - aDest) * pipe->cSrc[2] + aDest * cBlend[2]); cResult1 = div255((255 - aDest) * pipe->cSrc[1] + aDest * cBlend[1]); case splashPipeResultColorNoAlphaBlendMono: cResult0 = div255((255 - aDest) * pipe->cSrc[0] + aDest * cBlend[0]); break; case splashPipeResultColorAlphaNoBlendMono: if (alpha2 == 0) { cResult0 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * pipe->cSrc[0]) / alpha2); } break; case splashPipeResultColorAlphaNoBlendRGB: if (alpha2 == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * pipe->cSrc[0]) / alpha2); cResult1 = (Guchar)(((alpha2 - aSrc) * cDest[1] + aSrc * pipe->cSrc[1]) / alpha2); cResult2 = (Guchar)(((alpha2 - aSrc) * cDest[2] + aSrc * pipe->cSrc[2]) / alpha2); } break; #if SPLASH_CMYK case splashPipeResultColorAlphaNoBlendCMYK: if (alpha2 == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; cResult3 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * pipe->cSrc[0]) / alpha2); cResult1 = (Guchar)(((alpha2 - aSrc) * cDest[1] + aSrc * pipe->cSrc[1]) / alpha2); cResult2 = (Guchar)(((alpha2 - aSrc) * cDest[2] + aSrc * pipe->cSrc[2]) / alpha2); cResult3 = (Guchar)(((alpha2 - aSrc) * cDest[3] + aSrc * pipe->cSrc[3]) / alpha2); } break; #endif case splashPipeResultColorAlphaBlendMono: if (alpha2 == 0) { cResult0 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * ((255 - aDest) * pipe->cSrc[0] + aDest * cBlend[0]) / 255) / alpha2); } break; case splashPipeResultColorAlphaBlendRGB: if (alpha2 == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * ((255 - aDest) * pipe->cSrc[0] + aDest * cBlend[0]) / 255) / alpha2); cResult1 = (Guchar)(((alpha2 - aSrc) * cDest[1] + aSrc * ((255 - aDest) * pipe->cSrc[1] + aDest * cBlend[1]) / 255) / alpha2); cResult2 = (Guchar)(((alpha2 - aSrc) * cDest[2] + aSrc * ((255 - aDest) * pipe->cSrc[2] + aDest * cBlend[2]) / 255) / alpha2); } break; #if SPLASH_CMYK case splashPipeResultColorAlphaBlendCMYK: if (alpha2 == 0) { cResult0 = 0; cResult1 = 0; cResult2 = 0; cResult3 = 0; } else { cResult0 = (Guchar)(((alpha2 - aSrc) * cDest[0] + aSrc * ((255 - aDest) * pipe->cSrc[0] + aDest * cBlend[0]) / 255) / alpha2); cResult1 = (Guchar)(((alpha2 - aSrc) * cDest[1] + aSrc * ((255 - aDest) * pipe->cSrc[1] + aDest * cBlend[1]) / 255) / alpha2); cResult2 = (Guchar)(((alpha2 - aSrc) * cDest[2] + aSrc * ((255 - aDest) * pipe->cSrc[2] + aDest * cBlend[2]) / 255) / alpha2); cResult3 = (Guchar)(((alpha2 - aSrc) * cDest[3] + aSrc * ((255 - aDest) * pipe->cSrc[3] + aDest * cBlend[3]) / 255) / alpha2); } break; #endif } if (aResult != 0) { switch (pipe->nonIsolatedGroup) { #if SPLASH_CMYK case 4: cResult3 += (cResult3 - cDest[3]) * aDest * (255 - aResult) / (255 * aResult); #endif case 3: cResult2 += (cResult2 - cDest[2]) * aDest * (255 - aResult) / (255 * aResult); cResult1 += (cResult1 - cDest[1]) * aDest * (255 - aResult) / (255 * aResult); case 1: cResult0 += (cResult0 - cDest[0]) * aDest * (255 - aResult) / (255 * aResult); case 0: break; } } switch (bitmap->mode) { case splashModeMono1: if (state->screen->test(pipe->x, pipe->y, cResult0)) { *pipe->destColorPtr |= pipe->destColorMask; } else { *pipe->destColorPtr &= ~pipe->destColorMask; } if (!(pipe->destColorMask >>= 1)) { pipe->destColorMask = 0x80; ++pipe->destColorPtr; } break; case splashModeMono8: *pipe->destColorPtr++ = cResult0; break; case splashModeRGB8: *pipe->destColorPtr++ = cResult0; *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult2; break; case splashModeXBGR8: *pipe->destColorPtr++ = cResult2; *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult0; *pipe->destColorPtr++ = 255; break; case splashModeBGR8: *pipe->destColorPtr++ = cResult2; *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult0; break; #if SPLASH_CMYK case splashModeCMYK8: *pipe->destColorPtr++ = cResult0; *pipe->destColorPtr++ = cResult1; *pipe->destColorPtr++ = cResult2; *pipe->destColorPtr++ = cResult3; break; #endif } if (pipe->destAlphaPtr) { *pipe->destAlphaPtr++ = aResult; } } ++pipe->x; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,004
inline void Splash::pipeSetXY(SplashPipe *pipe, int x, int y) { pipe->x = x; pipe->y = y; if (state->softMask) { pipe->softMaskPtr = &state->softMask->data[y * state->softMask->rowSize + x]; } switch (bitmap->mode) { case splashModeMono1: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + (x >> 3)]; pipe->destColorMask = 0x80 >> (x & 7); break; case splashModeMono8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + x]; break; case splashModeRGB8: case splashModeBGR8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 3 * x]; break; case splashModeXBGR8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; break; #if SPLASH_CMYK case splashModeCMYK8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; break; #endif } if (bitmap->alpha) { pipe->destAlphaPtr = &bitmap->alpha[y * bitmap->width + x]; } else { pipe->destAlphaPtr = NULL; } if (state->inNonIsolatedGroup && alpha0Bitmap->alpha) { pipe->alpha0Ptr = &alpha0Bitmap->alpha[(alpha0Y + y) * alpha0Bitmap->width + (alpha0X + x)]; } else { pipe->alpha0Ptr = NULL; } }
DoS Exec Code Overflow
0
inline void Splash::pipeSetXY(SplashPipe *pipe, int x, int y) { pipe->x = x; pipe->y = y; if (state->softMask) { pipe->softMaskPtr = &state->softMask->data[y * state->softMask->rowSize + x]; } switch (bitmap->mode) { case splashModeMono1: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + (x >> 3)]; pipe->destColorMask = 0x80 >> (x & 7); break; case splashModeMono8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + x]; break; case splashModeRGB8: case splashModeBGR8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 3 * x]; break; case splashModeXBGR8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; break; #if SPLASH_CMYK case splashModeCMYK8: pipe->destColorPtr = &bitmap->data[y * bitmap->rowSize + 4 * x]; break; #endif } if (bitmap->alpha) { pipe->destAlphaPtr = &bitmap->alpha[y * bitmap->width + x]; } else { pipe->destAlphaPtr = NULL; } if (state->inNonIsolatedGroup && alpha0Bitmap->alpha) { pipe->alpha0Ptr = &alpha0Bitmap->alpha[(alpha0Y + y) * alpha0Bitmap->width + (alpha0X + x)]; } else { pipe->alpha0Ptr = NULL; } }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,005
SplashError Splash::restoreState() { SplashState *oldState; if (!state->next) { return splashErrNoSave; } oldState = state; state = state->next; delete oldState; return splashOk; }
DoS Exec Code Overflow
0
SplashError Splash::restoreState() { SplashState *oldState; if (!state->next) { return splashErrNoSave; } oldState = state; state = state->next; delete oldState; return splashOk; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,006
void Splash::saveState() { SplashState *newState; newState = state->copy(); newState->next = state; state = newState; }
DoS Exec Code Overflow
0
void Splash::saveState() { SplashState *newState; newState = state->copy(); newState->next = state; state = newState; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,007
void Splash::setBlendFunc(SplashBlendFunc func) { state->blendFunc = func; }
DoS Exec Code Overflow
0
void Splash::setBlendFunc(SplashBlendFunc func) { state->blendFunc = func; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,008
void Splash::setFlatness(SplashCoord flatness) { if (flatness < 1) { state->flatness = 1; } else { state->flatness = flatness; } }
DoS Exec Code Overflow
0
void Splash::setFlatness(SplashCoord flatness) { if (flatness < 1) { state->flatness = 1; } else { state->flatness = flatness; } }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,009
void Splash::setInNonIsolatedGroup(SplashBitmap *alpha0BitmapA, int alpha0XA, int alpha0YA) { alpha0Bitmap = alpha0BitmapA; alpha0X = alpha0XA; alpha0Y = alpha0YA; state->inNonIsolatedGroup = gTrue; }
DoS Exec Code Overflow
0
void Splash::setInNonIsolatedGroup(SplashBitmap *alpha0BitmapA, int alpha0XA, int alpha0YA) { alpha0Bitmap = alpha0BitmapA; alpha0X = alpha0XA; alpha0Y = alpha0YA; state->inNonIsolatedGroup = gTrue; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,010
void Splash::setLineCap(int lineCap) { state->lineCap = lineCap; }
DoS Exec Code Overflow
0
void Splash::setLineCap(int lineCap) { state->lineCap = lineCap; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,011
void Splash::setLineDash(SplashCoord *lineDash, int lineDashLength, SplashCoord lineDashPhase) { state->setLineDash(lineDash, lineDashLength, lineDashPhase); }
DoS Exec Code Overflow
0
void Splash::setLineDash(SplashCoord *lineDash, int lineDashLength, SplashCoord lineDashPhase) { state->setLineDash(lineDash, lineDashLength, lineDashPhase); }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,012
void Splash::setLineWidth(SplashCoord lineWidth) { state->lineWidth = lineWidth; }
DoS Exec Code Overflow
0
void Splash::setLineWidth(SplashCoord lineWidth) { state->lineWidth = lineWidth; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,013
void Splash::setMatrix(SplashCoord *matrix) { memcpy(state->matrix, matrix, 6 * sizeof(SplashCoord)); }
DoS Exec Code Overflow
0
void Splash::setMatrix(SplashCoord *matrix) { memcpy(state->matrix, matrix, 6 * sizeof(SplashCoord)); }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,014
void Splash::setScreen(SplashScreen *screen) { state->setScreen(screen); }
DoS Exec Code Overflow
0
void Splash::setScreen(SplashScreen *screen) { state->setScreen(screen); }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,015
void Splash::setSoftMask(SplashBitmap *softMask) { state->setSoftMask(softMask); }
DoS Exec Code Overflow
0
void Splash::setSoftMask(SplashBitmap *softMask) { state->setSoftMask(softMask); }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,016
void Splash::setStrokeAlpha(SplashCoord alpha) { state->strokeAlpha = alpha; }
DoS Exec Code Overflow
0
void Splash::setStrokeAlpha(SplashCoord alpha) { state->strokeAlpha = alpha; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,017
void Splash::setStrokePattern(SplashPattern *strokePattern) { state->setStrokePattern(strokePattern); }
DoS Exec Code Overflow
0
void Splash::setStrokePattern(SplashPattern *strokePattern) { state->setStrokePattern(strokePattern); }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,018
SplashError Splash::stroke(SplashPath *path) { SplashPath *path2, *dPath; if (debugMode) { printf("stroke [dash:%d] [width:%.2f]:\n", state->lineDashLength, (double)state->lineWidth); dumpPath(path); } opClipRes = splashClipAllOutside; if (path->length == 0) { return splashErrEmptyPath; } path2 = flattenPath(path, state->matrix, state->flatness); if (state->lineDashLength > 0) { dPath = makeDashedPath(path2); delete path2; path2 = dPath; } if (state->lineWidth == 0) { strokeNarrow(path2); } else { strokeWide(path2); } delete path2; return splashOk; }
DoS Exec Code Overflow
0
SplashError Splash::stroke(SplashPath *path) { SplashPath *path2, *dPath; if (debugMode) { printf("stroke [dash:%d] [width:%.2f]:\n", state->lineDashLength, (double)state->lineWidth); dumpPath(path); } opClipRes = splashClipAllOutside; if (path->length == 0) { return splashErrEmptyPath; } path2 = flattenPath(path, state->matrix, state->flatness); if (state->lineDashLength > 0) { dPath = makeDashedPath(path2); delete path2; path2 = dPath; } if (state->lineWidth == 0) { strokeNarrow(path2); } else { strokeWide(path2); } delete path2; return splashOk; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,019
void Splash::strokeWide(SplashPath *path) { SplashPath *path2; path2 = makeStrokePath(path, gFalse); fillWithPattern(path2, gFalse, state->strokePattern, state->strokeAlpha); delete path2; }
DoS Exec Code Overflow
0
void Splash::strokeWide(SplashPath *path) { SplashPath *path2; path2 = makeStrokePath(path, gFalse); fillWithPattern(path2, gFalse, state->strokePattern, state->strokeAlpha); delete path2; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,020
inline void Splash::transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi, SplashCoord *xo, SplashCoord *yo) { *xo = xi * matrix[0] + yi * matrix[2] + matrix[4]; *yo = xi * matrix[1] + yi * matrix[3] + matrix[5]; }
DoS Exec Code Overflow
0
inline void Splash::transform(SplashCoord *matrix, SplashCoord xi, SplashCoord yi, SplashCoord *xo, SplashCoord *yo) { *xo = xi * matrix[0] + yi * matrix[2] + matrix[4]; *yo = xi * matrix[1] + yi * matrix[3] + matrix[5]; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,021
inline void Splash::updateModX(int x) { if (x < modXMin) { modXMin = x; } if (x > modXMax) { modXMax = x; } }
DoS Exec Code Overflow
0
inline void Splash::updateModX(int x) { if (x < modXMin) { modXMin = x; } if (x > modXMax) { modXMax = x; } }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,022
SplashError Splash::xorFill(SplashPath *path, GBool eo) { SplashPipe pipe; SplashXPath *xPath; SplashXPathScanner *scanner; int xMinI, yMinI, xMaxI, yMaxI, x0, x1, y; SplashClipResult clipRes, clipRes2; SplashBlendFunc origBlendFunc; if (path->length == 0) { return splashErrEmptyPath; } xPath = new SplashXPath(path, state->matrix, state->flatness, gTrue); xPath->sort(); scanner = new SplashXPathScanner(xPath, eo); scanner->getBBox(&xMinI, &yMinI, &xMaxI, &yMaxI); if ((clipRes = state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI)) != splashClipAllOutside) { if (yMinI < state->clip->getYMinI()) { yMinI = state->clip->getYMinI(); } if (yMaxI > state->clip->getYMaxI()) { yMaxI = state->clip->getYMaxI(); } origBlendFunc = state->blendFunc; state->blendFunc = &blendXor; pipeInit(&pipe, 0, yMinI, state->fillPattern, NULL, 1, gFalse, gFalse); for (y = yMinI; y <= yMaxI; ++y) { while (scanner->getNextSpan(y, &x0, &x1)) { if (clipRes == splashClipAllInside) { drawSpan(&pipe, x0, x1, y, gTrue); } else { if (x0 < state->clip->getXMinI()) { x0 = state->clip->getXMinI(); } if (x1 > state->clip->getXMaxI()) { x1 = state->clip->getXMaxI(); } clipRes2 = state->clip->testSpan(x0, x1, y); drawSpan(&pipe, x0, x1, y, clipRes2 == splashClipAllInside); } } } state->blendFunc = origBlendFunc; } opClipRes = clipRes; delete scanner; delete xPath; return splashOk; }
DoS Exec Code Overflow
0
SplashError Splash::xorFill(SplashPath *path, GBool eo) { SplashPipe pipe; SplashXPath *xPath; SplashXPathScanner *scanner; int xMinI, yMinI, xMaxI, yMaxI, x0, x1, y; SplashClipResult clipRes, clipRes2; SplashBlendFunc origBlendFunc; if (path->length == 0) { return splashErrEmptyPath; } xPath = new SplashXPath(path, state->matrix, state->flatness, gTrue); xPath->sort(); scanner = new SplashXPathScanner(xPath, eo); scanner->getBBox(&xMinI, &yMinI, &xMaxI, &yMaxI); if ((clipRes = state->clip->testRect(xMinI, yMinI, xMaxI, yMaxI)) != splashClipAllOutside) { if (yMinI < state->clip->getYMinI()) { yMinI = state->clip->getYMinI(); } if (yMaxI > state->clip->getYMaxI()) { yMaxI = state->clip->getYMaxI(); } origBlendFunc = state->blendFunc; state->blendFunc = &blendXor; pipeInit(&pipe, 0, yMinI, state->fillPattern, NULL, 1, gFalse, gFalse); for (y = yMinI; y <= yMaxI; ++y) { while (scanner->getNextSpan(y, &x0, &x1)) { if (clipRes == splashClipAllInside) { drawSpan(&pipe, x0, x1, y, gTrue); } else { if (x0 < state->clip->getXMinI()) { x0 = state->clip->getXMinI(); } if (x1 > state->clip->getXMaxI()) { x1 = state->clip->getXMaxI(); } clipRes2 = state->clip->testSpan(x0, x1, y); drawSpan(&pipe, x0, x1, y, clipRes2 == splashClipAllInside); } } } state->blendFunc = origBlendFunc; } opClipRes = clipRes; delete scanner; delete xPath; return splashOk; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2005-2008 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2005-2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2005 Marco Pesenti Gritti <mpg@redhat.com> // // To see a description of the changes please see the Changelog file that @@ -2001,7 +2001,7 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffer - pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w); + pixBuf = (SplashColorPtr)gmallocn((yp + 1), w); // initialize the pixel pipe pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha, @@ -2301,9 +2301,9 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData, xq = w % scaledWidth; // allocate pixel buffers - colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps); + colorBuf = (SplashColorPtr)gmallocn3((yp + 1), w, nComps); if (srcAlpha) { - alphaBuf = (Guchar *)gmalloc((yp + 1) * w); + alphaBuf = (Guchar *)gmallocn((yp + 1), w); } else { alphaBuf = NULL; }
CWE-189
null
null
1,023
Guchar SplashBitmap::getAlpha(int x, int y) { return alpha[y * width + x]; }
DoS Exec Code Overflow
0
Guchar SplashBitmap::getAlpha(int x, int y) { return alpha[y * width + x]; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2006 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> // // To see a description of the changes please see the Changelog file that @@ -62,13 +62,13 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad, } rowSize += rowPad - 1; rowSize -= rowSize % rowPad; - data = (SplashColorPtr)gmalloc(rowSize * height); + data = (SplashColorPtr)gmallocn(rowSize, height); if (!topDown) { data += (height - 1) * rowSize; rowSize = -rowSize; } if (alphaA) { - alpha = (Guchar *)gmalloc(width * height); + alpha = (Guchar *)gmallocn(width, height); } else { alpha = NULL; }
CWE-189
null
null
1,024
SplashError SplashBitmap::writePNMFile(char *fileName) { FILE *f; SplashError e; if (!(f = fopen(fileName, "wb"))) { return splashErrOpenFile; } e = this->writePNMFile(f); fclose(f); return e; }
DoS Exec Code Overflow
0
SplashError SplashBitmap::writePNMFile(char *fileName) { FILE *f; SplashError e; if (!(f = fopen(fileName, "wb"))) { return splashErrOpenFile; } e = this->writePNMFile(f); fclose(f); return e; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2006 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> // // To see a description of the changes please see the Changelog file that @@ -62,13 +62,13 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad, } rowSize += rowPad - 1; rowSize -= rowSize % rowPad; - data = (SplashColorPtr)gmalloc(rowSize * height); + data = (SplashColorPtr)gmallocn(rowSize, height); if (!topDown) { data += (height - 1) * rowSize; rowSize = -rowSize; } if (alphaA) { - alpha = (Guchar *)gmalloc(width * height); + alpha = (Guchar *)gmallocn(width, height); } else { alpha = NULL; }
CWE-189
null
null
1,025
SplashError SplashBitmap::writePNMFile(FILE *f) { SplashColorPtr row, p; int x, y; switch (mode) { case splashModeMono1: fprintf(f, "P4\n%d %d\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; x += 8) { fputc(*p ^ 0xff, f); ++p; } row += rowSize; } break; case splashModeMono8: fprintf(f, "P5\n%d %d\n255\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; ++x) { fputc(*p, f); ++p; } row += rowSize; } break; case splashModeRGB8: fprintf(f, "P6\n%d %d\n255\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; ++x) { fputc(splashRGB8R(p), f); fputc(splashRGB8G(p), f); fputc(splashRGB8B(p), f); p += 3; } row += rowSize; } break; case splashModeXBGR8: fprintf(f, "P6\n%d %d\n255\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; ++x) { fputc(splashBGR8R(p), f); fputc(splashBGR8G(p), f); fputc(splashBGR8B(p), f); p += 4; } row += rowSize; } break; case splashModeBGR8: fprintf(f, "P6\n%d %d\n255\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; ++x) { fputc(splashBGR8R(p), f); fputc(splashBGR8G(p), f); fputc(splashBGR8B(p), f); p += 3; } row += rowSize; } break; #if SPLASH_CMYK case splashModeCMYK8: break; #endif } return splashOk; }
DoS Exec Code Overflow
0
SplashError SplashBitmap::writePNMFile(FILE *f) { SplashColorPtr row, p; int x, y; switch (mode) { case splashModeMono1: fprintf(f, "P4\n%d %d\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; x += 8) { fputc(*p ^ 0xff, f); ++p; } row += rowSize; } break; case splashModeMono8: fprintf(f, "P5\n%d %d\n255\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; ++x) { fputc(*p, f); ++p; } row += rowSize; } break; case splashModeRGB8: fprintf(f, "P6\n%d %d\n255\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; ++x) { fputc(splashRGB8R(p), f); fputc(splashRGB8G(p), f); fputc(splashRGB8B(p), f); p += 3; } row += rowSize; } break; case splashModeXBGR8: fprintf(f, "P6\n%d %d\n255\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; ++x) { fputc(splashBGR8R(p), f); fputc(splashBGR8G(p), f); fputc(splashBGR8B(p), f); p += 4; } row += rowSize; } break; case splashModeBGR8: fprintf(f, "P6\n%d %d\n255\n", width, height); row = data; for (y = 0; y < height; ++y) { p = row; for (x = 0; x < width; ++x) { fputc(splashBGR8R(p), f); fputc(splashBGR8G(p), f); fputc(splashBGR8B(p), f); p += 3; } row += rowSize; } break; #if SPLASH_CMYK case splashModeCMYK8: break; #endif } return splashOk; }
@@ -11,7 +11,7 @@ // All changes made under the Poppler project to this file are licensed // under GPL version 2 or later // -// Copyright (C) 2006 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2006, 2009 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2007 Ilmari Heikkinen <ilmari.heikkinen@gmail.com> // // To see a description of the changes please see the Changelog file that @@ -62,13 +62,13 @@ SplashBitmap::SplashBitmap(int widthA, int heightA, int rowPad, } rowSize += rowPad - 1; rowSize -= rowSize % rowPad; - data = (SplashColorPtr)gmalloc(rowSize * height); + data = (SplashColorPtr)gmallocn(rowSize, height); if (!topDown) { data += (height - 1) * rowSize; rowSize = -rowSize; } if (alphaA) { - alpha = (Guchar *)gmalloc(width * height); + alpha = (Guchar *)gmallocn(width, height); } else { alpha = NULL; }
CWE-189
null
null
1,026
GBool SplashFTFont::getGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { return SplashFont::getGlyph(c, xFrac, 0, bitmap, x0, y0, clip, clipRes); }
DoS Exec Code Overflow
0
GBool SplashFTFont::getGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) { return SplashFont::getGlyph(c, xFrac, 0, bitmap, x0, y0, clip, clipRes); }
@@ -243,7 +243,7 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, } else { rowSize = (bitmap->w + 7) >> 3; } - bitmap->data = (Guchar *)gmalloc(rowSize * bitmap->h); + bitmap->data = (Guchar *)gmallocn(rowSize, bitmap->h); bitmap->freeData = gTrue; for (i = 0, p = bitmap->data, q = slot->bitmap.buffer; i < bitmap->h;
CWE-189
null
null
1,027
SplashPath *SplashFTFont::getGlyphPath(int c) { static FT_Outline_Funcs outlineFuncs = { #if FREETYPE_MINOR <= 1 (int (*)(FT_Vector *, void *))&glyphPathMoveTo, (int (*)(FT_Vector *, void *))&glyphPathLineTo, (int (*)(FT_Vector *, FT_Vector *, void *))&glyphPathConicTo, (int (*)(FT_Vector *, FT_Vector *, FT_Vector *, void *))&glyphPathCubicTo, #else &glyphPathMoveTo, &glyphPathLineTo, &glyphPathConicTo, &glyphPathCubicTo, #endif 0, 0 }; SplashFTFontFile *ff; SplashFTFontPath path; FT_GlyphSlot slot; FT_UInt gid; FT_Glyph glyph; ff = (SplashFTFontFile *)fontFile; ff->face->size = sizeObj; FT_Set_Transform(ff->face, &textMatrix, NULL); slot = ff->face->glyph; if (ff->codeToGID && c < ff->codeToGIDLen) { gid = ff->codeToGID[c]; } else { gid = (FT_UInt)c; } if (ff->trueType && gid == 0) { return NULL; } if (FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP)) { return NULL; } if (FT_Get_Glyph(slot, &glyph)) { return NULL; } path.path = new SplashPath(); path.textScale = textScale; path.needClose = gFalse; FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline, &outlineFuncs, &path); if (path.needClose) { path.path->close(); } FT_Done_Glyph(glyph); return path.path; }
DoS Exec Code Overflow
0
SplashPath *SplashFTFont::getGlyphPath(int c) { static FT_Outline_Funcs outlineFuncs = { #if FREETYPE_MINOR <= 1 (int (*)(FT_Vector *, void *))&glyphPathMoveTo, (int (*)(FT_Vector *, void *))&glyphPathLineTo, (int (*)(FT_Vector *, FT_Vector *, void *))&glyphPathConicTo, (int (*)(FT_Vector *, FT_Vector *, FT_Vector *, void *))&glyphPathCubicTo, #else &glyphPathMoveTo, &glyphPathLineTo, &glyphPathConicTo, &glyphPathCubicTo, #endif 0, 0 }; SplashFTFontFile *ff; SplashFTFontPath path; FT_GlyphSlot slot; FT_UInt gid; FT_Glyph glyph; ff = (SplashFTFontFile *)fontFile; ff->face->size = sizeObj; FT_Set_Transform(ff->face, &textMatrix, NULL); slot = ff->face->glyph; if (ff->codeToGID && c < ff->codeToGIDLen) { gid = ff->codeToGID[c]; } else { gid = (FT_UInt)c; } if (ff->trueType && gid == 0) { return NULL; } if (FT_Load_Glyph(ff->face, gid, FT_LOAD_NO_BITMAP)) { return NULL; } if (FT_Get_Glyph(slot, &glyph)) { return NULL; } path.path = new SplashPath(); path.textScale = textScale; path.needClose = gFalse; FT_Outline_Decompose(&((FT_OutlineGlyph)glyph)->outline, &outlineFuncs, &path); if (path.needClose) { path.path->close(); } FT_Done_Glyph(glyph); return path.path; }
@@ -243,7 +243,7 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, } else { rowSize = (bitmap->w + 7) >> 3; } - bitmap->data = (Guchar *)gmalloc(rowSize * bitmap->h); + bitmap->data = (Guchar *)gmallocn(rowSize, bitmap->h); bitmap->freeData = gTrue; for (i = 0, p = bitmap->data, q = slot->bitmap.buffer; i < bitmap->h;
CWE-189
null
null
1,028
static int glyphPathConicTo(const FT_Vector *ctrl, const FT_Vector *pt, void *path) { SplashFTFontPath *p = (SplashFTFontPath *)path; SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xc, yc; if (!p->path->getCurPt(&x0, &y0)) { return 0; } xc = (SplashCoord)ctrl->x * p->textScale / 64.0; yc = (SplashCoord)ctrl->y * p->textScale / 64.0; x3 = (SplashCoord)pt->x * p->textScale / 64.0; y3 = (SplashCoord)pt->y * p->textScale / 64.0; x1 = (SplashCoord)(1.0 / 3.0) * (x0 + (SplashCoord)2 * xc); y1 = (SplashCoord)(1.0 / 3.0) * (y0 + (SplashCoord)2 * yc); x2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * xc + x3); y2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * yc + y3); p->path->curveTo(x1, y1, x2, y2, x3, y3); p->needClose = gTrue; return 0; }
DoS Exec Code Overflow
0
static int glyphPathConicTo(const FT_Vector *ctrl, const FT_Vector *pt, void *path) { SplashFTFontPath *p = (SplashFTFontPath *)path; SplashCoord x0, y0, x1, y1, x2, y2, x3, y3, xc, yc; if (!p->path->getCurPt(&x0, &y0)) { return 0; } xc = (SplashCoord)ctrl->x * p->textScale / 64.0; yc = (SplashCoord)ctrl->y * p->textScale / 64.0; x3 = (SplashCoord)pt->x * p->textScale / 64.0; y3 = (SplashCoord)pt->y * p->textScale / 64.0; x1 = (SplashCoord)(1.0 / 3.0) * (x0 + (SplashCoord)2 * xc); y1 = (SplashCoord)(1.0 / 3.0) * (y0 + (SplashCoord)2 * yc); x2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * xc + x3); y2 = (SplashCoord)(1.0 / 3.0) * ((SplashCoord)2 * yc + y3); p->path->curveTo(x1, y1, x2, y2, x3, y3); p->needClose = gTrue; return 0; }
@@ -243,7 +243,7 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, } else { rowSize = (bitmap->w + 7) >> 3; } - bitmap->data = (Guchar *)gmalloc(rowSize * bitmap->h); + bitmap->data = (Guchar *)gmallocn(rowSize, bitmap->h); bitmap->freeData = gTrue; for (i = 0, p = bitmap->data, q = slot->bitmap.buffer; i < bitmap->h;
CWE-189
null
null
1,029
SplashFTFont::~SplashFTFont() { }
DoS Exec Code Overflow
0
SplashFTFont::~SplashFTFont() { }
@@ -243,7 +243,7 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac, } else { rowSize = (bitmap->w + 7) >> 3; } - bitmap->data = (Guchar *)gmalloc(rowSize * bitmap->h); + bitmap->data = (Guchar *)gmallocn(rowSize, bitmap->h); bitmap->freeData = gTrue; for (i = 0, p = bitmap->data, q = slot->bitmap.buffer; i < bitmap->h;
CWE-189
null
null
1,030
void gMemReport(FILE *f) { GMemHdr *p; fprintf(f, "%d memory allocations in all\n", gMemIndex); if (gMemAlloc > 0) { fprintf(f, "%d memory blocks left allocated:\n", gMemAlloc); fprintf(f, " index size\n"); fprintf(f, "-------- --------\n"); for (p = gMemHead; p; p = p->next) { fprintf(f, "%8d %8d\n", p->index, p->size); } } else { fprintf(f, "No memory blocks left allocated\n"); } }
DoS Exec Code Overflow
0
void gMemReport(FILE *f) { GMemHdr *p; fprintf(f, "%d memory allocations in all\n", gMemIndex); if (gMemAlloc > 0) { fprintf(f, "%d memory blocks left allocated:\n", gMemAlloc); fprintf(f, " index size\n"); fprintf(f, "-------- --------\n"); for (p = gMemHead; p; p = p->next) { fprintf(f, "%8d %8d\n", p->index, p->size); } } else { fprintf(f, "No memory blocks left allocated\n"); } }
@@ -216,6 +216,28 @@ void *gmallocn_checkoverflow(int nObjs, int objSize) GMEM_EXCEP { return gmallocn(nObjs, objSize, true); } +inline static void *gmallocn3(int a, int b, int c, bool checkoverflow) GMEM_EXCEP { + int n = a * b; + if (b <= 0 || a < 0 || a >= INT_MAX / b) { +#if USE_EXCEPTIONS + throw GMemException(); +#else + fprintf(stderr, "Bogus memory allocation size\n"); + if (checkoverflow) return NULL; + else exit(1); +#endif + } + return gmallocn(n, c, checkoverflow); +} + +void *gmallocn3(int a, int b, int c) GMEM_EXCEP { + return gmallocn3(a, b, c, false); +} + +void *gmallocn3_checkoverflow(int a, int b, int c) GMEM_EXCEP { + return gmallocn3(a, b, c, true); +} + inline static void *greallocn(void *p, int nObjs, int objSize, bool checkoverflow) GMEM_EXCEP { int n;
CWE-399
null
null
1,031
pair<const EntityDescriptor*,const RoleDescriptor*> DynamicMetadataProvider::getEntityDescriptor(const Criteria& criteria) const { Category& log = Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic"); bool writeLocked = false; pair<const EntityDescriptor*,const RoleDescriptor*> entity = AbstractMetadataProvider::getEntityDescriptor(criteria); cachemap_t::iterator cit; if (entity.first) { cit = m_cacheMap.find(entity.first->getEntityID()); } else if (criteria.entityID_ascii) { auto_ptr_XMLCh widetemp(criteria.entityID_ascii); cit = m_cacheMap.find(widetemp.get()); } else if (criteria.entityID_unicode) { cit = m_cacheMap.find(criteria.entityID_unicode); } else if (criteria.artifact) { auto_ptr_XMLCh widetemp(criteria.artifact->getSource().c_str()); cit = m_cacheMap.find(widetemp.get()); } else { cit = m_cacheMap.end(); } if (cit != m_cacheMap.end()) { if (time(nullptr) <= cit->second) return entity; } string name; if (criteria.entityID_ascii) { name = criteria.entityID_ascii; } else if (criteria.entityID_unicode) { auto_ptr_char temp(criteria.entityID_unicode); name = temp.get(); } else if (criteria.artifact) { name = criteria.artifact->getSource(); } else { return entity; } if (entity.first) log.info("metadata for (%s) is beyond caching interval, attempting to refresh", name.c_str()); else log.info("resolving metadata for (%s)", name.c_str()); try { auto_ptr<EntityDescriptor> entity2(resolve(criteria)); if (criteria.entityID_unicode && !XMLString::equals(criteria.entityID_unicode, entity2->getEntityID())) { log.error("metadata instance did not match expected entityID"); return entity; } else if (criteria.artifact) { auto_ptr_char temp2(entity2->getEntityID()); const string hashed(SecurityHelper::doHash("SHA1", temp2.get(), strlen(temp2.get()), true)); if (hashed != name) { log.error("metadata instance did not match expected entityID"); return entity; } } else { auto_ptr_XMLCh temp2(name.c_str()); if (!XMLString::equals(temp2.get(), entity2->getEntityID())) { log.error("metadata instance did not match expected entityID"); return entity; } } try { SchemaValidators.validate(entity2.get()); } catch (exception& ex) { log.error("metadata instance failed manual validation checking: %s", ex.what()); throw MetadataException("Metadata instance failed manual validation checking."); } doFilters(*entity2); time_t now = time(nullptr); time_t cmp = now; if (cmp < (std::numeric_limits<int>::max() - 60)) cmp += 60; if (entity2->getValidUntil() && entity2->getValidUntilEpoch() < cmp) throw MetadataException("Metadata was already invalid at the time of retrieval."); log.info("caching resolved metadata for (%s)", name.c_str()); time_t cacheExp = (entity2->getValidUntil() ? entity2->getValidUntilEpoch() : SAMLTIME_MAX) - now; if (entity2->getCacheDuration()) cacheExp = min(cacheExp, entity2->getCacheDurationEpoch()); cacheExp *= m_refreshDelayFactor; if (cacheExp > m_maxCacheDuration) cacheExp = m_maxCacheDuration; else if (cacheExp < m_minCacheDuration) cacheExp = m_minCacheDuration; log.info("next refresh of metadata for (%s) no sooner than %u seconds", name.c_str(), cacheExp); m_lock->unlock(); m_lock->wrlock(); writeLocked = true; emitChangeEvent(*entity2); m_cacheMap[entity2->getEntityID()] = now + cacheExp; cacheExp = SAMLTIME_MAX; unindex(entity2->getEntityID(), true); // actually frees the old instance with this ID indexEntity(entity2.get(), cacheExp); entity2.release(); m_lastUpdate = now; } catch (exception& e) { log.error("error while resolving entityID (%s): %s", name.c_str(), e.what()); if (!writeLocked) { m_lock->unlock(); m_lock->wrlock(); writeLocked = true; } if (entity.first) m_cacheMap[entity.first->getEntityID()] = time(nullptr) + m_minCacheDuration; else if (criteria.entityID_unicode) m_cacheMap[criteria.entityID_unicode] = time(nullptr) + m_minCacheDuration; else { auto_ptr_XMLCh widetemp(name.c_str()); m_cacheMap[widetemp.get()] = time(nullptr) + m_minCacheDuration; } log.warn("next refresh of metadata for (%s) no sooner than %u seconds", name.c_str(), m_minCacheDuration); return entity; } if (writeLocked) { m_lock->unlock(); m_lock->rdlock(); } return getEntityDescriptor(criteria); }
null
0
pair<const EntityDescriptor*,const RoleDescriptor*> DynamicMetadataProvider::getEntityDescriptor(const Criteria& criteria) const { Category& log = Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic"); bool writeLocked = false; pair<const EntityDescriptor*,const RoleDescriptor*> entity = AbstractMetadataProvider::getEntityDescriptor(criteria); cachemap_t::iterator cit; if (entity.first) { cit = m_cacheMap.find(entity.first->getEntityID()); } else if (criteria.entityID_ascii) { auto_ptr_XMLCh widetemp(criteria.entityID_ascii); cit = m_cacheMap.find(widetemp.get()); } else if (criteria.entityID_unicode) { cit = m_cacheMap.find(criteria.entityID_unicode); } else if (criteria.artifact) { auto_ptr_XMLCh widetemp(criteria.artifact->getSource().c_str()); cit = m_cacheMap.find(widetemp.get()); } else { cit = m_cacheMap.end(); } if (cit != m_cacheMap.end()) { if (time(nullptr) <= cit->second) return entity; } string name; if (criteria.entityID_ascii) { name = criteria.entityID_ascii; } else if (criteria.entityID_unicode) { auto_ptr_char temp(criteria.entityID_unicode); name = temp.get(); } else if (criteria.artifact) { name = criteria.artifact->getSource(); } else { return entity; } if (entity.first) log.info("metadata for (%s) is beyond caching interval, attempting to refresh", name.c_str()); else log.info("resolving metadata for (%s)", name.c_str()); try { auto_ptr<EntityDescriptor> entity2(resolve(criteria)); if (criteria.entityID_unicode && !XMLString::equals(criteria.entityID_unicode, entity2->getEntityID())) { log.error("metadata instance did not match expected entityID"); return entity; } else if (criteria.artifact) { auto_ptr_char temp2(entity2->getEntityID()); const string hashed(SecurityHelper::doHash("SHA1", temp2.get(), strlen(temp2.get()), true)); if (hashed != name) { log.error("metadata instance did not match expected entityID"); return entity; } } else { auto_ptr_XMLCh temp2(name.c_str()); if (!XMLString::equals(temp2.get(), entity2->getEntityID())) { log.error("metadata instance did not match expected entityID"); return entity; } } try { SchemaValidators.validate(entity2.get()); } catch (exception& ex) { log.error("metadata instance failed manual validation checking: %s", ex.what()); throw MetadataException("Metadata instance failed manual validation checking."); } doFilters(*entity2); time_t now = time(nullptr); time_t cmp = now; if (cmp < (std::numeric_limits<int>::max() - 60)) cmp += 60; if (entity2->getValidUntil() && entity2->getValidUntilEpoch() < cmp) throw MetadataException("Metadata was already invalid at the time of retrieval."); log.info("caching resolved metadata for (%s)", name.c_str()); time_t cacheExp = (entity2->getValidUntil() ? entity2->getValidUntilEpoch() : SAMLTIME_MAX) - now; if (entity2->getCacheDuration()) cacheExp = min(cacheExp, entity2->getCacheDurationEpoch()); cacheExp *= m_refreshDelayFactor; if (cacheExp > m_maxCacheDuration) cacheExp = m_maxCacheDuration; else if (cacheExp < m_minCacheDuration) cacheExp = m_minCacheDuration; log.info("next refresh of metadata for (%s) no sooner than %u seconds", name.c_str(), cacheExp); m_lock->unlock(); m_lock->wrlock(); writeLocked = true; emitChangeEvent(*entity2); m_cacheMap[entity2->getEntityID()] = now + cacheExp; cacheExp = SAMLTIME_MAX; unindex(entity2->getEntityID(), true); // actually frees the old instance with this ID indexEntity(entity2.get(), cacheExp); entity2.release(); m_lastUpdate = now; } catch (exception& e) { log.error("error while resolving entityID (%s): %s", name.c_str(), e.what()); if (!writeLocked) { m_lock->unlock(); m_lock->wrlock(); writeLocked = true; } if (entity.first) m_cacheMap[entity.first->getEntityID()] = time(nullptr) + m_minCacheDuration; else if (criteria.entityID_unicode) m_cacheMap[criteria.entityID_unicode] = time(nullptr) + m_minCacheDuration; else { auto_ptr_XMLCh widetemp(name.c_str()); m_cacheMap[widetemp.get()] = time(nullptr) + m_minCacheDuration; } log.warn("next refresh of metadata for (%s) no sooner than %u seconds", name.c_str(), m_minCacheDuration); return entity; } if (writeLocked) { m_lock->unlock(); m_lock->rdlock(); } return getEntityDescriptor(criteria); }
@@ -79,7 +79,7 @@ namespace opensaml { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : AbstractMetadataProvider(e), + : AbstractMetadataProvider(e), MetadataProvider(e), m_validate(XMLHelper::getAttrBool(e, false, validate)), m_id(XMLHelper::getAttrString(e, "Dynamic", id)), m_lock(RWLock::create()), @@ -92,7 +92,7 @@ DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) m_cleanup_wait(nullptr), m_cleanup_thread(nullptr) { if (m_minCacheDuration > m_maxCacheDuration) { - Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error( + Category::getInstance(SAML_LOGCAT ".Metadata.Dynamic").error( "minCacheDuration setting exceeds maxCacheDuration setting, lowering to match it" ); m_minCacheDuration = m_maxCacheDuration;
CWE-347
null
null
1,032
const XMLObject* DynamicMetadataProvider::getMetadata() const { throw MetadataException("getMetadata operation not implemented on this provider."); }
null
0
const XMLObject* DynamicMetadataProvider::getMetadata() const { throw MetadataException("getMetadata operation not implemented on this provider."); }
@@ -79,7 +79,7 @@ namespace opensaml { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : AbstractMetadataProvider(e), + : AbstractMetadataProvider(e), MetadataProvider(e), m_validate(XMLHelper::getAttrBool(e, false, validate)), m_id(XMLHelper::getAttrString(e, "Dynamic", id)), m_lock(RWLock::create()), @@ -92,7 +92,7 @@ DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) m_cleanup_wait(nullptr), m_cleanup_thread(nullptr) { if (m_minCacheDuration > m_maxCacheDuration) { - Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error( + Category::getInstance(SAML_LOGCAT ".Metadata.Dynamic").error( "minCacheDuration setting exceeds maxCacheDuration setting, lowering to match it" ); m_minCacheDuration = m_maxCacheDuration;
CWE-347
null
null
1,033
Lockable* DynamicMetadataProvider::lock() { m_lock->rdlock(); return this; }
null
0
Lockable* DynamicMetadataProvider::lock() { m_lock->rdlock(); return this; }
@@ -79,7 +79,7 @@ namespace opensaml { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : AbstractMetadataProvider(e), + : AbstractMetadataProvider(e), MetadataProvider(e), m_validate(XMLHelper::getAttrBool(e, false, validate)), m_id(XMLHelper::getAttrString(e, "Dynamic", id)), m_lock(RWLock::create()), @@ -92,7 +92,7 @@ DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) m_cleanup_wait(nullptr), m_cleanup_thread(nullptr) { if (m_minCacheDuration > m_maxCacheDuration) { - Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error( + Category::getInstance(SAML_LOGCAT ".Metadata.Dynamic").error( "minCacheDuration setting exceeds maxCacheDuration setting, lowering to match it" ); m_minCacheDuration = m_maxCacheDuration;
CWE-347
null
null
1,034
EntityDescriptor* DynamicMetadataProvider::resolve(const Criteria& criteria) const { string name; if (criteria.entityID_ascii) { name = criteria.entityID_ascii; } else if (criteria.entityID_unicode) { auto_ptr_char temp(criteria.entityID_unicode); name = temp.get(); } else if (criteria.artifact) { throw MetadataException("Unable to resolve metadata dynamically from an artifact."); } try { DOMDocument* doc=nullptr; auto_ptr_XMLCh widenit(name.c_str()); URLInputSource src(widenit.get()); Wrapper4InputSource dsrc(&src,false); if (m_validate) doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc); else doc=XMLToolingConfig::getConfig().getParser().parse(dsrc); XercesJanitor<DOMDocument> docjanitor(doc); auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true)); docjanitor.release(); EntityDescriptor* entity = dynamic_cast<EntityDescriptor*>(xmlObject.get()); if (!entity) { throw MetadataException( "Root of metadata instance not recognized: $1", params(1,xmlObject->getElementQName().toString().c_str()) ); } xmlObject.release(); return entity; } catch (XMLException& e) { auto_ptr_char msg(e.getMessage()); Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error( "Xerces error while resolving entityID (%s): %s", name.c_str(), msg.get() ); throw MetadataException(msg.get()); } }
null
0
EntityDescriptor* DynamicMetadataProvider::resolve(const Criteria& criteria) const { string name; if (criteria.entityID_ascii) { name = criteria.entityID_ascii; } else if (criteria.entityID_unicode) { auto_ptr_char temp(criteria.entityID_unicode); name = temp.get(); } else if (criteria.artifact) { throw MetadataException("Unable to resolve metadata dynamically from an artifact."); } try { DOMDocument* doc=nullptr; auto_ptr_XMLCh widenit(name.c_str()); URLInputSource src(widenit.get()); Wrapper4InputSource dsrc(&src,false); if (m_validate) doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc); else doc=XMLToolingConfig::getConfig().getParser().parse(dsrc); XercesJanitor<DOMDocument> docjanitor(doc); auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true)); docjanitor.release(); EntityDescriptor* entity = dynamic_cast<EntityDescriptor*>(xmlObject.get()); if (!entity) { throw MetadataException( "Root of metadata instance not recognized: $1", params(1,xmlObject->getElementQName().toString().c_str()) ); } xmlObject.release(); return entity; } catch (XMLException& e) { auto_ptr_char msg(e.getMessage()); Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error( "Xerces error while resolving entityID (%s): %s", name.c_str(), msg.get() ); throw MetadataException(msg.get()); } }
@@ -79,7 +79,7 @@ namespace opensaml { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : AbstractMetadataProvider(e), + : AbstractMetadataProvider(e), MetadataProvider(e), m_validate(XMLHelper::getAttrBool(e, false, validate)), m_id(XMLHelper::getAttrString(e, "Dynamic", id)), m_lock(RWLock::create()), @@ -92,7 +92,7 @@ DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) m_cleanup_wait(nullptr), m_cleanup_thread(nullptr) { if (m_minCacheDuration > m_maxCacheDuration) { - Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error( + Category::getInstance(SAML_LOGCAT ".Metadata.Dynamic").error( "minCacheDuration setting exceeds maxCacheDuration setting, lowering to match it" ); m_minCacheDuration = m_maxCacheDuration;
CWE-347
null
null
1,035
void DynamicMetadataProvider::unlock() { m_lock->unlock(); }
null
0
void DynamicMetadataProvider::unlock() { m_lock->unlock(); }
@@ -79,7 +79,7 @@ namespace opensaml { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : AbstractMetadataProvider(e), + : AbstractMetadataProvider(e), MetadataProvider(e), m_validate(XMLHelper::getAttrBool(e, false, validate)), m_id(XMLHelper::getAttrString(e, "Dynamic", id)), m_lock(RWLock::create()), @@ -92,7 +92,7 @@ DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) m_cleanup_wait(nullptr), m_cleanup_thread(nullptr) { if (m_minCacheDuration > m_maxCacheDuration) { - Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error( + Category::getInstance(SAML_LOGCAT ".Metadata.Dynamic").error( "minCacheDuration setting exceeds maxCacheDuration setting, lowering to match it" ); m_minCacheDuration = m_maxCacheDuration;
CWE-347
null
null
1,036
DynamicMetadataProvider::~DynamicMetadataProvider() { clearDescriptorIndex(true); if (m_cleanup_thread) { m_shutdown = true; m_cleanup_wait->signal(); m_cleanup_thread->join(nullptr); delete m_cleanup_thread; delete m_cleanup_wait; m_cleanup_thread = nullptr; m_cleanup_wait = nullptr; } }
null
0
DynamicMetadataProvider::~DynamicMetadataProvider() { clearDescriptorIndex(true); if (m_cleanup_thread) { m_shutdown = true; m_cleanup_wait->signal(); m_cleanup_thread->join(nullptr); delete m_cleanup_thread; delete m_cleanup_wait; m_cleanup_thread = nullptr; m_cleanup_wait = nullptr; } }
@@ -79,7 +79,7 @@ namespace opensaml { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : AbstractMetadataProvider(e), + : AbstractMetadataProvider(e), MetadataProvider(e), m_validate(XMLHelper::getAttrBool(e, false, validate)), m_id(XMLHelper::getAttrString(e, "Dynamic", id)), m_lock(RWLock::create()), @@ -92,7 +92,7 @@ DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) m_cleanup_wait(nullptr), m_cleanup_thread(nullptr) { if (m_minCacheDuration > m_maxCacheDuration) { - Category::getInstance(SAML_LOGCAT ".MetadataProvider.Dynamic").error( + Category::getInstance(SAML_LOGCAT ".Metadata.Dynamic").error( "minCacheDuration setting exceeds maxCacheDuration setting, lowering to match it" ); m_minCacheDuration = m_maxCacheDuration;
CWE-347
null
null
1,037
saml2md::MetadataProvider* SHIBSP_DLLLOCAL DynamicMetadataProviderFactory(const DOMElement* const & e) { return new DynamicMetadataProvider(e); }
null
0
saml2md::MetadataProvider* SHIBSP_DLLLOCAL DynamicMetadataProviderFactory(const DOMElement* const & e) { return new DynamicMetadataProvider(e); }
@@ -95,7 +95,7 @@ namespace shibsp { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : saml2md::DynamicMetadataProvider(e), + : saml2md::DynamicMetadataProvider(e), MetadataProvider(e), m_verifyHost(XMLHelper::getAttrBool(e, true, verifyHost)), m_ignoreTransport(XMLHelper::getAttrBool(e, false, ignoreTransport)), m_encoded(true), m_trust(nullptr)
CWE-347
null
null
1,038
saml2md::EntityDescriptor* DynamicMetadataProvider::resolve(const saml2md::MetadataProvider::Criteria& criteria) const { #ifdef _DEBUG xmltooling::NDC("resolve"); #endif Category& log=Category::getInstance(SHIBSP_LOGCAT ".MetadataProvider.Dynamic"); string name; if (criteria.entityID_ascii) { name = criteria.entityID_ascii; } else if (criteria.entityID_unicode) { auto_ptr_char temp(criteria.entityID_unicode); name = temp.get(); } else if (criteria.artifact) { if (m_subst.empty() && (m_regex.empty() || m_match.empty())) throw saml2md::MetadataException("Unable to resolve metadata dynamically from an artifact."); name = "{sha1}" + criteria.artifact->getSource(); } if (!m_subst.empty()) { string name2(name); if (!m_hashed.empty()) { name2 = SecurityHelper::doHash(m_hashed.c_str(), name.c_str(), name.length()); } name2 = boost::replace_first_copy(m_subst, "$entityID", m_encoded ? XMLToolingConfig::getConfig().getURLEncoder()->encode(name2.c_str()) : name2); log.info("transformed location from (%s) to (%s)", name.c_str(), name2.c_str()); name = name2; } else if (!m_match.empty() && !m_regex.empty()) { try { RegularExpression exp(m_match.c_str()); XMLCh* temp = exp.replace(name.c_str(), m_regex.c_str()); if (temp) { auto_ptr_char narrow(temp); XMLString::release(&temp); if (name != narrow.get()) { log.info("transformed location from (%s) to (%s)", name.c_str(), narrow.get()); name = narrow.get(); } } } catch (XMLException& ex) { auto_ptr_char msg(ex.getMessage()); log.error("caught error applying regular expression: %s", msg.get()); } } if (XMLString::startsWithI(name.c_str(), "file://")) { MetadataProvider::Criteria baseCriteria(name.c_str()); return saml2md::DynamicMetadataProvider::resolve(baseCriteria); } const MetadataProviderCriteria* mpc = dynamic_cast<const MetadataProviderCriteria*>(&criteria); if (!mpc) throw saml2md::MetadataException("Dynamic MetadataProvider requires Shibboleth-aware lookup criteria, check calling code."); const PropertySet* relyingParty; if (criteria.artifact) relyingParty = mpc->application.getRelyingParty((XMLCh*)nullptr); else if (criteria.entityID_unicode) relyingParty = mpc->application.getRelyingParty(criteria.entityID_unicode); else { auto_ptr_XMLCh temp2(name.c_str()); relyingParty = mpc->application.getRelyingParty(temp2.get()); } SOAPTransport::Address addr(relyingParty->getString("entityID").second, name.c_str(), name.c_str()); const char* pch = strchr(addr.m_endpoint,':'); if (!pch) throw IOException("location was not a URL."); string scheme(addr.m_endpoint, pch-addr.m_endpoint); boost::scoped_ptr<SOAPTransport> transport; try { transport.reset(XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), addr)); } catch (exception& ex) { log.error("exception while building transport object to resolve URL: %s", ex.what()); throw IOException("Unable to resolve entityID with a known transport protocol."); } transport->setVerifyHost(m_verifyHost); if (m_trust.get() && m_dummyCR.get() && !transport->setTrustEngine(m_trust.get(), m_dummyCR.get())) throw IOException("Unable to install X509TrustEngine into transport object."); Locker credlocker(nullptr, false); CredentialResolver* credResolver = nullptr; pair<bool,const char*> authType=relyingParty->getString("authType"); if (!authType.first || !strcmp(authType.second,"TLS")) { credResolver = mpc->application.getCredentialResolver(); if (credResolver) credlocker.assign(credResolver); if (credResolver) { CredentialCriteria cc; cc.setUsage(Credential::TLS_CREDENTIAL); authType = relyingParty->getString("keyName"); if (authType.first) cc.getKeyNames().insert(authType.second); const Credential* cred = credResolver->resolve(&cc); cc.getKeyNames().clear(); if (cred) { if (!transport->setCredential(cred)) log.error("failed to load Credential into metadata resolver"); } else { log.error("no TLS credential supplied"); } } else { log.error("no CredentialResolver available for TLS"); } } else { SOAPTransport::transport_auth_t type=SOAPTransport::transport_auth_none; pair<bool,const char*> username=relyingParty->getString("authUsername"); pair<bool,const char*> password=relyingParty->getString("authPassword"); if (!username.first || !password.first) log.error("transport authType (%s) specified but authUsername or authPassword was missing", authType.second); else if (!strcmp(authType.second,"basic")) type = SOAPTransport::transport_auth_basic; else if (!strcmp(authType.second,"digest")) type = SOAPTransport::transport_auth_digest; else if (!strcmp(authType.second,"ntlm")) type = SOAPTransport::transport_auth_ntlm; else if (!strcmp(authType.second,"gss")) type = SOAPTransport::transport_auth_gss; else if (strcmp(authType.second,"none")) log.error("unknown authType (%s) specified for RelyingParty", authType.second); if (type > SOAPTransport::transport_auth_none) { if (transport->setAuth(type,username.second,password.second)) log.debug("configured for transport authentication (method=%s, username=%s)", authType.second, username.second); else log.error("failed to configure transport authentication (method=%s)", authType.second); } } pair<bool,unsigned int> timeout = relyingParty->getUnsignedInt("connectTimeout"); transport->setConnectTimeout(timeout.first ? timeout.second : 10); timeout = relyingParty->getUnsignedInt("timeout"); transport->setTimeout(timeout.first ? timeout.second : 20); mpc->application.getServiceProvider().setTransportOptions(*transport); HTTPSOAPTransport* http = dynamic_cast<HTTPSOAPTransport*>(transport.get()); if (http) { pair<bool,bool> flag = relyingParty->getBool("chunkedEncoding"); http->useChunkedEncoding(flag.first && flag.second); http->setRequestHeader("Xerces-C", XERCES_FULLVERSIONDOT); http->setRequestHeader("XML-Security-C", XSEC_FULLVERSIONDOT); http->setRequestHeader("OpenSAML-C", gOpenSAMLDotVersionStr); http->setRequestHeader(PACKAGE_NAME, PACKAGE_VERSION); } try { transport->send(); istream& msg = transport->receive(); DOMDocument* doc=nullptr; StreamInputSource src(msg, "DynamicMetadataProvider"); Wrapper4InputSource dsrc(&src,false); if (m_validate) doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc); else doc=XMLToolingConfig::getConfig().getParser().parse(dsrc); XercesJanitor<DOMDocument> docjanitor(doc); if (!doc->getDocumentElement() || !XMLHelper::isNodeNamed(doc->getDocumentElement(), samlconstants::SAML20MD_NS, saml2md::EntityDescriptor::LOCAL_NAME)) { throw saml2md::MetadataException("Root of metadata instance was not an EntityDescriptor"); } auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true)); docjanitor.release(); saml2md::EntityDescriptor* entity = dynamic_cast<saml2md::EntityDescriptor*>(xmlObject.get()); if (!entity) { throw saml2md::MetadataException( "Root of metadata instance not recognized: $1", params(1,xmlObject->getElementQName().toString().c_str()) ); } xmlObject.release(); return entity; } catch (XMLException& e) { auto_ptr_char msg(e.getMessage()); log.error("Xerces error while resolving location (%s): %s", name.c_str(), msg.get()); throw saml2md::MetadataException(msg.get()); } }
null
0
saml2md::EntityDescriptor* DynamicMetadataProvider::resolve(const saml2md::MetadataProvider::Criteria& criteria) const { #ifdef _DEBUG xmltooling::NDC("resolve"); #endif Category& log=Category::getInstance(SHIBSP_LOGCAT ".MetadataProvider.Dynamic"); string name; if (criteria.entityID_ascii) { name = criteria.entityID_ascii; } else if (criteria.entityID_unicode) { auto_ptr_char temp(criteria.entityID_unicode); name = temp.get(); } else if (criteria.artifact) { if (m_subst.empty() && (m_regex.empty() || m_match.empty())) throw saml2md::MetadataException("Unable to resolve metadata dynamically from an artifact."); name = "{sha1}" + criteria.artifact->getSource(); } if (!m_subst.empty()) { string name2(name); if (!m_hashed.empty()) { name2 = SecurityHelper::doHash(m_hashed.c_str(), name.c_str(), name.length()); } name2 = boost::replace_first_copy(m_subst, "$entityID", m_encoded ? XMLToolingConfig::getConfig().getURLEncoder()->encode(name2.c_str()) : name2); log.info("transformed location from (%s) to (%s)", name.c_str(), name2.c_str()); name = name2; } else if (!m_match.empty() && !m_regex.empty()) { try { RegularExpression exp(m_match.c_str()); XMLCh* temp = exp.replace(name.c_str(), m_regex.c_str()); if (temp) { auto_ptr_char narrow(temp); XMLString::release(&temp); if (name != narrow.get()) { log.info("transformed location from (%s) to (%s)", name.c_str(), narrow.get()); name = narrow.get(); } } } catch (XMLException& ex) { auto_ptr_char msg(ex.getMessage()); log.error("caught error applying regular expression: %s", msg.get()); } } if (XMLString::startsWithI(name.c_str(), "file://")) { MetadataProvider::Criteria baseCriteria(name.c_str()); return saml2md::DynamicMetadataProvider::resolve(baseCriteria); } const MetadataProviderCriteria* mpc = dynamic_cast<const MetadataProviderCriteria*>(&criteria); if (!mpc) throw saml2md::MetadataException("Dynamic MetadataProvider requires Shibboleth-aware lookup criteria, check calling code."); const PropertySet* relyingParty; if (criteria.artifact) relyingParty = mpc->application.getRelyingParty((XMLCh*)nullptr); else if (criteria.entityID_unicode) relyingParty = mpc->application.getRelyingParty(criteria.entityID_unicode); else { auto_ptr_XMLCh temp2(name.c_str()); relyingParty = mpc->application.getRelyingParty(temp2.get()); } SOAPTransport::Address addr(relyingParty->getString("entityID").second, name.c_str(), name.c_str()); const char* pch = strchr(addr.m_endpoint,':'); if (!pch) throw IOException("location was not a URL."); string scheme(addr.m_endpoint, pch-addr.m_endpoint); boost::scoped_ptr<SOAPTransport> transport; try { transport.reset(XMLToolingConfig::getConfig().SOAPTransportManager.newPlugin(scheme.c_str(), addr)); } catch (exception& ex) { log.error("exception while building transport object to resolve URL: %s", ex.what()); throw IOException("Unable to resolve entityID with a known transport protocol."); } transport->setVerifyHost(m_verifyHost); if (m_trust.get() && m_dummyCR.get() && !transport->setTrustEngine(m_trust.get(), m_dummyCR.get())) throw IOException("Unable to install X509TrustEngine into transport object."); Locker credlocker(nullptr, false); CredentialResolver* credResolver = nullptr; pair<bool,const char*> authType=relyingParty->getString("authType"); if (!authType.first || !strcmp(authType.second,"TLS")) { credResolver = mpc->application.getCredentialResolver(); if (credResolver) credlocker.assign(credResolver); if (credResolver) { CredentialCriteria cc; cc.setUsage(Credential::TLS_CREDENTIAL); authType = relyingParty->getString("keyName"); if (authType.first) cc.getKeyNames().insert(authType.second); const Credential* cred = credResolver->resolve(&cc); cc.getKeyNames().clear(); if (cred) { if (!transport->setCredential(cred)) log.error("failed to load Credential into metadata resolver"); } else { log.error("no TLS credential supplied"); } } else { log.error("no CredentialResolver available for TLS"); } } else { SOAPTransport::transport_auth_t type=SOAPTransport::transport_auth_none; pair<bool,const char*> username=relyingParty->getString("authUsername"); pair<bool,const char*> password=relyingParty->getString("authPassword"); if (!username.first || !password.first) log.error("transport authType (%s) specified but authUsername or authPassword was missing", authType.second); else if (!strcmp(authType.second,"basic")) type = SOAPTransport::transport_auth_basic; else if (!strcmp(authType.second,"digest")) type = SOAPTransport::transport_auth_digest; else if (!strcmp(authType.second,"ntlm")) type = SOAPTransport::transport_auth_ntlm; else if (!strcmp(authType.second,"gss")) type = SOAPTransport::transport_auth_gss; else if (strcmp(authType.second,"none")) log.error("unknown authType (%s) specified for RelyingParty", authType.second); if (type > SOAPTransport::transport_auth_none) { if (transport->setAuth(type,username.second,password.second)) log.debug("configured for transport authentication (method=%s, username=%s)", authType.second, username.second); else log.error("failed to configure transport authentication (method=%s)", authType.second); } } pair<bool,unsigned int> timeout = relyingParty->getUnsignedInt("connectTimeout"); transport->setConnectTimeout(timeout.first ? timeout.second : 10); timeout = relyingParty->getUnsignedInt("timeout"); transport->setTimeout(timeout.first ? timeout.second : 20); mpc->application.getServiceProvider().setTransportOptions(*transport); HTTPSOAPTransport* http = dynamic_cast<HTTPSOAPTransport*>(transport.get()); if (http) { pair<bool,bool> flag = relyingParty->getBool("chunkedEncoding"); http->useChunkedEncoding(flag.first && flag.second); http->setRequestHeader("Xerces-C", XERCES_FULLVERSIONDOT); http->setRequestHeader("XML-Security-C", XSEC_FULLVERSIONDOT); http->setRequestHeader("OpenSAML-C", gOpenSAMLDotVersionStr); http->setRequestHeader(PACKAGE_NAME, PACKAGE_VERSION); } try { transport->send(); istream& msg = transport->receive(); DOMDocument* doc=nullptr; StreamInputSource src(msg, "DynamicMetadataProvider"); Wrapper4InputSource dsrc(&src,false); if (m_validate) doc=XMLToolingConfig::getConfig().getValidatingParser().parse(dsrc); else doc=XMLToolingConfig::getConfig().getParser().parse(dsrc); XercesJanitor<DOMDocument> docjanitor(doc); if (!doc->getDocumentElement() || !XMLHelper::isNodeNamed(doc->getDocumentElement(), samlconstants::SAML20MD_NS, saml2md::EntityDescriptor::LOCAL_NAME)) { throw saml2md::MetadataException("Root of metadata instance was not an EntityDescriptor"); } auto_ptr<XMLObject> xmlObject(XMLObjectBuilder::buildOneFromElement(doc->getDocumentElement(), true)); docjanitor.release(); saml2md::EntityDescriptor* entity = dynamic_cast<saml2md::EntityDescriptor*>(xmlObject.get()); if (!entity) { throw saml2md::MetadataException( "Root of metadata instance not recognized: $1", params(1,xmlObject->getElementQName().toString().c_str()) ); } xmlObject.release(); return entity; } catch (XMLException& e) { auto_ptr_char msg(e.getMessage()); log.error("Xerces error while resolving location (%s): %s", name.c_str(), msg.get()); throw saml2md::MetadataException(msg.get()); } }
@@ -95,7 +95,7 @@ namespace shibsp { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : saml2md::DynamicMetadataProvider(e), + : saml2md::DynamicMetadataProvider(e), MetadataProvider(e), m_verifyHost(XMLHelper::getAttrBool(e, true, verifyHost)), m_ignoreTransport(XMLHelper::getAttrBool(e, false, ignoreTransport)), m_encoded(true), m_trust(nullptr)
CWE-347
null
null
1,039
virtual ~DynamicMetadataProvider() {}
null
0
virtual ~DynamicMetadataProvider() {}
@@ -95,7 +95,7 @@ namespace shibsp { }; DynamicMetadataProvider::DynamicMetadataProvider(const DOMElement* e) - : saml2md::DynamicMetadataProvider(e), + : saml2md::DynamicMetadataProvider(e), MetadataProvider(e), m_verifyHost(XMLHelper::getAttrBool(e, true, verifyHost)), m_ignoreTransport(XMLHelper::getAttrBool(e, false, ignoreTransport)), m_encoded(true), m_trust(nullptr)
CWE-347
null
null
1,040
static __be32 *__xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) { __be32 *p = xdr->p; __be32 *q = p + XDR_QUADLEN(nbytes); if (q > xdr->end || q < p) return NULL; xdr->p = q; return p; }
Overflow
0
static __be32 *__xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) { __be32 *p = xdr->p; __be32 *q = p + XDR_QUADLEN(nbytes); if (q > xdr->end || q < p) return NULL; xdr->p = q; return p; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,041
static int decode_filename(struct xdr_stream *xdr, char *name, u32 *length) { __be32 *p; u32 count; p = xdr_inline_decode(xdr, 4); if (!p) goto out_overflow; count = ntoh32(net_read_uint32(p)); if (count > 255) goto out_nametoolong; p = xdr_inline_decode(xdr, count); if (!p) goto out_overflow; memcpy(name, p, count); name[count] = 0; *length = count; return 0; out_nametoolong: pr_err("%s: returned a too long filename: %u\n", __func__, count); return -ENAMETOOLONG; out_overflow: pr_err("%s: premature end of packet\n", __func__); return -EIO; }
Overflow
0
static int decode_filename(struct xdr_stream *xdr, char *name, u32 *length) { __be32 *p; u32 count; p = xdr_inline_decode(xdr, 4); if (!p) goto out_overflow; count = ntoh32(net_read_uint32(p)); if (count > 255) goto out_nametoolong; p = xdr_inline_decode(xdr, count); if (!p) goto out_overflow; memcpy(name, p, count); name[count] = 0; *length = count; return 0; out_nametoolong: pr_err("%s: returned a too long filename: %u\n", __func__, count); return -ENAMETOOLONG; out_overflow: pr_err("%s: premature end of packet\n", __func__); return -EIO; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,042
static uint32_t *nfs_add_fh3(uint32_t *p, struct nfs_fh *fh) { *p++ = hton32(fh->size); /* zero padding */ if (fh->size & 3) p[fh->size / 4] = 0; memcpy(p, fh->data, fh->size); p += DIV_ROUND_UP(fh->size, 4); return p; }
Overflow
0
static uint32_t *nfs_add_fh3(uint32_t *p, struct nfs_fh *fh) { *p++ = hton32(fh->size); /* zero padding */ if (fh->size & 3) p[fh->size / 4] = 0; memcpy(p, fh->data, fh->size); p += DIV_ROUND_UP(fh->size, 4); return p; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,043
static uint32_t *nfs_add_filename(uint32_t *p, uint32_t filename_len, const char *filename) { *p++ = hton32(filename_len); /* zero padding */ if (filename_len & 3) p[filename_len / 4] = 0; memcpy(p, filename, filename_len); p += DIV_ROUND_UP(filename_len, 4); return p; }
Overflow
0
static uint32_t *nfs_add_filename(uint32_t *p, uint32_t filename_len, const char *filename) { *p++ = hton32(filename_len); /* zero padding */ if (filename_len & 3) p[filename_len / 4] = 0; memcpy(p, filename, filename_len); p += DIV_ROUND_UP(filename_len, 4); return p; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,044
static uint32_t *nfs_add_uint64(uint32_t *p, uint64_t val) { uint64_t nval = hton64(val); memcpy(p, &nval, 8); return p + 2; }
Overflow
0
static uint32_t *nfs_add_uint64(uint32_t *p, uint64_t val) { uint64_t nval = hton64(val); memcpy(p, &nval, 8); return p + 2; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,045
static struct inode *nfs_alloc_inode(struct super_block *sb) { struct nfs_inode *node; node = xzalloc(sizeof(*node)); if (!node) return NULL; return &node->inode; }
Overflow
0
static struct inode *nfs_alloc_inode(struct super_block *sb) { struct nfs_inode *node; node = xzalloc(sizeof(*node)); if (!node) return NULL; return &node->inode; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,046
static void nfs_do_close(struct file_priv *priv) { if (priv->fifo) kfifo_free(priv->fifo); free(priv); }
Overflow
0
static void nfs_do_close(struct file_priv *priv) { if (priv->fifo) kfifo_free(priv->fifo); free(priv); }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,047
static int nfs_fattr3_to_stat(uint32_t *p, struct inode *inode) { uint32_t mode; size_t i; if (!inode) return 0; /* offsetof(struct fattr3, type) = 0 */ switch (ntoh32(net_read_uint32(p + 0))) { case NF3REG: inode->i_mode = S_IFREG; break; case NF3DIR: inode->i_mode = S_IFDIR; break; case NF3BLK: inode->i_mode = S_IFBLK; break; case NF3CHR: inode->i_mode = S_IFCHR; break; case NF3LNK: inode->i_mode = S_IFLNK; break; case NF3SOCK: inode->i_mode = S_IFSOCK; break; case NF3FIFO: inode->i_mode = S_IFIFO; break; default: printf("%s: invalid mode %x\n", __func__, ntoh32(net_read_uint32(p + 0))); return -EIO; } /* offsetof(struct fattr3, mode) = 4 */ mode = ntoh32(net_read_uint32(p + 1)); for (i = 0; i < ARRAY_SIZE(nfs3_mode_bits); ++i) { if (mode & nfs3_mode_bits[i].nfsmode) inode->i_mode |= nfs3_mode_bits[i].statmode; } /* offsetof(struct fattr3, size) = 20 */ inode->i_size = ntoh64(net_read_uint64(p + 5)); return 0; }
Overflow
0
static int nfs_fattr3_to_stat(uint32_t *p, struct inode *inode) { uint32_t mode; size_t i; if (!inode) return 0; /* offsetof(struct fattr3, type) = 0 */ switch (ntoh32(net_read_uint32(p + 0))) { case NF3REG: inode->i_mode = S_IFREG; break; case NF3DIR: inode->i_mode = S_IFDIR; break; case NF3BLK: inode->i_mode = S_IFBLK; break; case NF3CHR: inode->i_mode = S_IFCHR; break; case NF3LNK: inode->i_mode = S_IFLNK; break; case NF3SOCK: inode->i_mode = S_IFSOCK; break; case NF3FIFO: inode->i_mode = S_IFIFO; break; default: printf("%s: invalid mode %x\n", __func__, ntoh32(net_read_uint32(p + 0))); return -EIO; } /* offsetof(struct fattr3, mode) = 4 */ mode = ntoh32(net_read_uint32(p + 1)); for (i = 0; i < ARRAY_SIZE(nfs3_mode_bits); ++i) { if (mode & nfs3_mode_bits[i].nfsmode) inode->i_mode |= nfs3_mode_bits[i].statmode; } /* offsetof(struct fattr3, size) = 20 */ inode->i_size = ntoh64(net_read_uint64(p + 5)); return 0; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,048
static const char *nfs_get_link(struct dentry *dentry, struct inode *inode) { struct nfs_inode *ninode = nfsi(inode); struct nfs_priv *npriv = ninode->npriv; int ret; ret = nfs_readlink_req(npriv, &ninode->fh, &inode->i_link); if (ret) return ERR_PTR(ret); return inode->i_link; }
Overflow
0
static const char *nfs_get_link(struct dentry *dentry, struct inode *inode) { struct nfs_inode *ninode = nfsi(inode); struct nfs_priv *npriv = ninode->npriv; int ret; ret = nfs_readlink_req(npriv, &ninode->fh, &inode->i_link); if (ret) return ERR_PTR(ret); return inode->i_link; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,049
static int nfs_init(void) { rootnfsopts = xstrdup("v3,tcp"); globalvar_add_simple_string("linux.rootnfsopts", &rootnfsopts); return register_fs_driver(&nfs_driver); }
Overflow
0
static int nfs_init(void) { rootnfsopts = xstrdup("v3,tcp"); globalvar_add_simple_string("linux.rootnfsopts", &rootnfsopts); return register_fs_driver(&nfs_driver); }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,050
static int nfs_init_inode(struct nfs_priv *npriv, struct inode *inode, unsigned int mode) { struct nfs_inode *ninode = nfsi(inode); ninode->npriv = npriv; inode->i_ino = get_next_ino(); inode->i_mode = mode; switch (inode->i_mode & S_IFMT) { default: return -EINVAL; case S_IFREG: inode->i_op = &nfs_file_inode_operations; inode->i_fop = &nfs_file_operations; break; case S_IFDIR: inode->i_op = &nfs_dir_inode_operations; inode->i_fop = &nfs_dir_operations; inc_nlink(inode); break; case S_IFLNK: inode->i_op = &nfs_symlink_inode_operations; break; } return 0; }
Overflow
0
static int nfs_init_inode(struct nfs_priv *npriv, struct inode *inode, unsigned int mode) { struct nfs_inode *ninode = nfsi(inode); ninode->npriv = npriv; inode->i_ino = get_next_ino(); inode->i_mode = mode; switch (inode->i_mode & S_IFMT) { default: return -EINVAL; case S_IFREG: inode->i_op = &nfs_file_inode_operations; inode->i_fop = &nfs_file_operations; break; case S_IFDIR: inode->i_op = &nfs_dir_inode_operations; inode->i_fop = &nfs_dir_operations; inc_nlink(inode); break; case S_IFLNK: inode->i_op = &nfs_symlink_inode_operations; break; } return 0; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,051
static int nfs_iterate(struct file *file, struct dir_context *ctx) { struct dentry *dentry = file->f_path.dentry; struct inode *dir = d_inode(dentry); struct nfs_priv *npriv = nfsi(dir)->npriv; void *buf = NULL; struct nfs_dir *ndir; struct xdr_stream *xdr; int ret; uint32_t *p, len; ndir = xzalloc(sizeof(*ndir)); ndir->fh = nfsi(dir)->fh; while (1) { /* cookie == 0 and cookieverf == 0 means start of dir */ buf = nfs_readdirattr_req(npriv, ndir); if (!buf) { pr_err("%s: nfs_readdirattr_req failed\n", __func__); ret = -EINVAL; goto out; } xdr = &ndir->stream; while (1) { char name[256]; p = xdr_inline_decode(xdr, 4); if (!p) goto err_eop; if (!net_read_uint32(p)) { /* eof? */ p = xdr_inline_decode(xdr, 4); if (!p) goto err_eop; if (net_read_uint32(p)) { ret = 0; goto out; } break; } /* skip over fileid */ p = xdr_inline_decode(xdr, 8); if (!p) goto err_eop; ret = decode_filename(xdr, name, &len); if (ret) goto out; dir_emit(ctx, name, len, 0, DT_UNKNOWN); p = xdr_inline_decode(xdr, 8); if (!p) goto err_eop; ndir->cookie = ntoh64(net_read_uint64(p)); } free(buf); } ret = 0; out: free(ndir->stream.buf); free(ndir); return ret; err_eop: pr_err("Unexpected end of packet\n"); return -EIO; }
Overflow
0
static int nfs_iterate(struct file *file, struct dir_context *ctx) { struct dentry *dentry = file->f_path.dentry; struct inode *dir = d_inode(dentry); struct nfs_priv *npriv = nfsi(dir)->npriv; void *buf = NULL; struct nfs_dir *ndir; struct xdr_stream *xdr; int ret; uint32_t *p, len; ndir = xzalloc(sizeof(*ndir)); ndir->fh = nfsi(dir)->fh; while (1) { /* cookie == 0 and cookieverf == 0 means start of dir */ buf = nfs_readdirattr_req(npriv, ndir); if (!buf) { pr_err("%s: nfs_readdirattr_req failed\n", __func__); ret = -EINVAL; goto out; } xdr = &ndir->stream; while (1) { char name[256]; p = xdr_inline_decode(xdr, 4); if (!p) goto err_eop; if (!net_read_uint32(p)) { /* eof? */ p = xdr_inline_decode(xdr, 4); if (!p) goto err_eop; if (net_read_uint32(p)) { ret = 0; goto out; } break; } /* skip over fileid */ p = xdr_inline_decode(xdr, 8); if (!p) goto err_eop; ret = decode_filename(xdr, name, &len); if (ret) goto out; dir_emit(ctx, name, len, 0, DT_UNKNOWN); p = xdr_inline_decode(xdr, 8); if (!p) goto err_eop; ndir->cookie = ntoh64(net_read_uint64(p)); } free(buf); } ret = 0; out: free(ndir->stream.buf); free(ndir); return ret; err_eop: pr_err("Unexpected end of packet\n"); return -EIO; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,052
static int nfs_lseek(struct device_d *dev, FILE *file, loff_t pos) { struct file_priv *priv = file->priv; kfifo_reset(priv->fifo); return 0; }
Overflow
0
static int nfs_lseek(struct device_d *dev, FILE *file, loff_t pos) { struct file_priv *priv = file->priv; kfifo_reset(priv->fifo); return 0; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,053
static int nfs_mount_req(struct nfs_priv *npriv) { uint32_t data[1024]; uint32_t *p; int len; int pathlen; struct packet *nfs_packet; pathlen = strlen(npriv->path); debug("%s: %s\n", __func__, npriv->path); p = &(data[0]); p = rpc_add_credentials(p); *p++ = hton32(pathlen); if (pathlen & 3) *(p + pathlen / 4) = 0; memcpy (p, npriv->path, pathlen); p += (pathlen + 3) / 4; len = p - &(data[0]); nfs_packet = rpc_req(npriv, PROG_MOUNT, MOUNT_ADDENTRY, data, len); if (IS_ERR(nfs_packet)) return PTR_ERR(nfs_packet); p = (void *)nfs_packet->data + sizeof(struct rpc_reply) + 4; npriv->rootfh.size = ntoh32(net_read_uint32(p++)); if (npriv->rootfh.size > NFS3_FHSIZE) { printf("%s: file handle too big: %lu\n", __func__, (unsigned long)npriv->rootfh.size); free(nfs_packet); return -EIO; } memcpy(npriv->rootfh.data, p, npriv->rootfh.size); free(nfs_packet); return 0; }
Overflow
0
static int nfs_mount_req(struct nfs_priv *npriv) { uint32_t data[1024]; uint32_t *p; int len; int pathlen; struct packet *nfs_packet; pathlen = strlen(npriv->path); debug("%s: %s\n", __func__, npriv->path); p = &(data[0]); p = rpc_add_credentials(p); *p++ = hton32(pathlen); if (pathlen & 3) *(p + pathlen / 4) = 0; memcpy (p, npriv->path, pathlen); p += (pathlen + 3) / 4; len = p - &(data[0]); nfs_packet = rpc_req(npriv, PROG_MOUNT, MOUNT_ADDENTRY, data, len); if (IS_ERR(nfs_packet)) return PTR_ERR(nfs_packet); p = (void *)nfs_packet->data + sizeof(struct rpc_reply) + 4; npriv->rootfh.size = ntoh32(net_read_uint32(p++)); if (npriv->rootfh.size > NFS3_FHSIZE) { printf("%s: file handle too big: %lu\n", __func__, (unsigned long)npriv->rootfh.size); free(nfs_packet); return -EIO; } memcpy(npriv->rootfh.data, p, npriv->rootfh.size); free(nfs_packet); return 0; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,054
static int nfs_open(struct device_d *dev, FILE *file, const char *filename) { struct inode *inode = file->f_inode; struct nfs_inode *ninode = nfsi(inode); struct nfs_priv *npriv = ninode->npriv; struct file_priv *priv; priv = xzalloc(sizeof(*priv)); priv->fh = ninode->fh; priv->npriv = npriv; file->priv = priv; file->size = inode->i_size; priv->fifo = kfifo_alloc(1024); if (!priv->fifo) { free(priv); return -ENOMEM; } return 0; }
Overflow
0
static int nfs_open(struct device_d *dev, FILE *file, const char *filename) { struct inode *inode = file->f_inode; struct nfs_inode *ninode = nfsi(inode); struct nfs_priv *npriv = ninode->npriv; struct file_priv *priv; priv = xzalloc(sizeof(*priv)); priv->fh = ninode->fh; priv->npriv = npriv; file->priv = priv; file->size = inode->i_size; priv->fifo = kfifo_alloc(1024); if (!priv->fifo) { free(priv); return -ENOMEM; } return 0; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,055
static uint32_t *nfs_read_post_op_attr(uint32_t *p, struct inode *inode) { /* * union post_op_attr switch (bool attributes_follow) { * case TRUE: * fattr3 attributes; * case FALSE: * void; * }; */ if (ntoh32(net_read_uint32(p++))) { nfs_fattr3_to_stat(p, inode); p += 21; } return p; }
Overflow
0
static uint32_t *nfs_read_post_op_attr(uint32_t *p, struct inode *inode) { /* * union post_op_attr switch (bool attributes_follow) { * case TRUE: * fattr3 attributes; * case FALSE: * void; * }; */ if (ntoh32(net_read_uint32(p++))) { nfs_fattr3_to_stat(p, inode); p += 21; } return p; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,056
static int nfs_read_req(struct file_priv *priv, uint64_t offset, uint32_t readlen) { uint32_t data[1024]; uint32_t *p; int len; struct packet *nfs_packet; uint32_t rlen, eof; /* * struct READ3args { * nfs_fh3 file; * offset3 offset; * count3 count; * }; * * struct READ3resok { * post_op_attr file_attributes; * count3 count; * bool eof; * opaque data<>; * }; * * struct READ3resfail { * post_op_attr file_attributes; * }; * * union READ3res switch (nfsstat3 status) { * case NFS3_OK: * READ3resok resok; * default: * READ3resfail resfail; * }; */ p = &(data[0]); p = rpc_add_credentials(p); p = nfs_add_fh3(p, &priv->fh); p = nfs_add_uint64(p, offset); p = nfs_add_uint32(p, readlen); len = p - &(data[0]); nfs_packet = rpc_req(priv->npriv, PROG_NFS, NFSPROC3_READ, data, len); if (IS_ERR(nfs_packet)) return PTR_ERR(nfs_packet); p = (void *)nfs_packet->data + sizeof(struct rpc_reply) + 4; p = nfs_read_post_op_attr(p, NULL); rlen = ntoh32(net_read_uint32(p)); /* skip over count */ p += 1; eof = ntoh32(net_read_uint32(p)); /* * skip over eof and count embedded in the representation of data * assuming it equals rlen above. */ p += 2; if (readlen && !rlen && !eof) { free(nfs_packet); return -EIO; } kfifo_put(priv->fifo, (char *)p, rlen); free(nfs_packet); return 0; }
Overflow
0
static int nfs_read_req(struct file_priv *priv, uint64_t offset, uint32_t readlen) { uint32_t data[1024]; uint32_t *p; int len; struct packet *nfs_packet; uint32_t rlen, eof; /* * struct READ3args { * nfs_fh3 file; * offset3 offset; * count3 count; * }; * * struct READ3resok { * post_op_attr file_attributes; * count3 count; * bool eof; * opaque data<>; * }; * * struct READ3resfail { * post_op_attr file_attributes; * }; * * union READ3res switch (nfsstat3 status) { * case NFS3_OK: * READ3resok resok; * default: * READ3resfail resfail; * }; */ p = &(data[0]); p = rpc_add_credentials(p); p = nfs_add_fh3(p, &priv->fh); p = nfs_add_uint64(p, offset); p = nfs_add_uint32(p, readlen); len = p - &(data[0]); nfs_packet = rpc_req(priv->npriv, PROG_NFS, NFSPROC3_READ, data, len); if (IS_ERR(nfs_packet)) return PTR_ERR(nfs_packet); p = (void *)nfs_packet->data + sizeof(struct rpc_reply) + 4; p = nfs_read_post_op_attr(p, NULL); rlen = ntoh32(net_read_uint32(p)); /* skip over count */ p += 1; eof = ntoh32(net_read_uint32(p)); /* * skip over eof and count embedded in the representation of data * assuming it equals rlen above. */ p += 2; if (readlen && !rlen && !eof) { free(nfs_packet); return -EIO; } kfifo_put(priv->fifo, (char *)p, rlen); free(nfs_packet); return 0; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,057
static void *nfs_readdirattr_req(struct nfs_priv *npriv, struct nfs_dir *dir) { uint32_t data[1024]; uint32_t *p; int len; struct packet *nfs_packet; void *buf; /* * struct READDIR3args { * nfs_fh3 dir; * cookie3 cookie; * cookieverf3 cookieverf; * count3 count; * }; * * struct entry3 { * fileid3 fileid; * filename3 name; * cookie3 cookie; * entry3 *nextentry; * }; * * struct dirlist3 { * entry3 *entries; * bool eof; * }; * * struct READDIR3resok { * post_op_attr dir_attributes; * cookieverf3 cookieverf; * dirlist3 reply; * }; * * struct READDIR3resfail { * post_op_attr dir_attributes; * }; * * union READDIR3res switch (nfsstat3 status) { * case NFS3_OK: * READDIR3resok resok; * default: * READDIR3resfail resfail; * }; */ p = &(data[0]); p = rpc_add_credentials(p); p = nfs_add_fh3(p, &dir->fh); p = nfs_add_uint64(p, dir->cookie); memcpy(p, dir->cookieverf, NFS3_COOKIEVERFSIZE); p += NFS3_COOKIEVERFSIZE / 4; p = nfs_add_uint32(p, 1024); /* count */ nfs_packet = rpc_req(npriv, PROG_NFS, NFSPROC3_READDIR, data, p - data); if (IS_ERR(nfs_packet)) return NULL; p = (void *)nfs_packet->data + sizeof(struct rpc_reply) + 4; p = nfs_read_post_op_attr(p, NULL); /* update cookieverf */ memcpy(dir->cookieverf, p, NFS3_COOKIEVERFSIZE); p += NFS3_COOKIEVERFSIZE / 4; len = (void *)nfs_packet->data + nfs_packet->len - (void *)p; if (!len) { printf("%s: huh, no payload left\n", __func__); free(nfs_packet); return NULL; } buf = xzalloc(len); memcpy(buf, p, len); free(nfs_packet); xdr_init(&dir->stream, buf, len); /* now xdr points to dirlist3 res.resok.reply */ return buf; }
Overflow
0
static void *nfs_readdirattr_req(struct nfs_priv *npriv, struct nfs_dir *dir) { uint32_t data[1024]; uint32_t *p; int len; struct packet *nfs_packet; void *buf; /* * struct READDIR3args { * nfs_fh3 dir; * cookie3 cookie; * cookieverf3 cookieverf; * count3 count; * }; * * struct entry3 { * fileid3 fileid; * filename3 name; * cookie3 cookie; * entry3 *nextentry; * }; * * struct dirlist3 { * entry3 *entries; * bool eof; * }; * * struct READDIR3resok { * post_op_attr dir_attributes; * cookieverf3 cookieverf; * dirlist3 reply; * }; * * struct READDIR3resfail { * post_op_attr dir_attributes; * }; * * union READDIR3res switch (nfsstat3 status) { * case NFS3_OK: * READDIR3resok resok; * default: * READDIR3resfail resfail; * }; */ p = &(data[0]); p = rpc_add_credentials(p); p = nfs_add_fh3(p, &dir->fh); p = nfs_add_uint64(p, dir->cookie); memcpy(p, dir->cookieverf, NFS3_COOKIEVERFSIZE); p += NFS3_COOKIEVERFSIZE / 4; p = nfs_add_uint32(p, 1024); /* count */ nfs_packet = rpc_req(npriv, PROG_NFS, NFSPROC3_READDIR, data, p - data); if (IS_ERR(nfs_packet)) return NULL; p = (void *)nfs_packet->data + sizeof(struct rpc_reply) + 4; p = nfs_read_post_op_attr(p, NULL); /* update cookieverf */ memcpy(dir->cookieverf, p, NFS3_COOKIEVERFSIZE); p += NFS3_COOKIEVERFSIZE / 4; len = (void *)nfs_packet->data + nfs_packet->len - (void *)p; if (!len) { printf("%s: huh, no payload left\n", __func__); free(nfs_packet); return NULL; } buf = xzalloc(len); memcpy(buf, p, len); free(nfs_packet); xdr_init(&dir->stream, buf, len); /* now xdr points to dirlist3 res.resok.reply */ return buf; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,058
static void nfs_remove(struct device_d *dev) { struct nfs_priv *npriv = dev->priv; nfs_umount_req(npriv); net_unregister(npriv->con); free(npriv->path); free(npriv); }
Overflow
0
static void nfs_remove(struct device_d *dev) { struct nfs_priv *npriv = dev->priv; nfs_umount_req(npriv); net_unregister(npriv->con); free(npriv->path); free(npriv); }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,059
static void nfs_set_fh(struct inode *inode, struct nfs_fh *fh) { struct nfs_inode *ninode = nfsi(inode); ninode->fh = *fh; }
Overflow
0
static void nfs_set_fh(struct inode *inode, struct nfs_fh *fh) { struct nfs_inode *ninode = nfsi(inode); ninode->fh = *fh; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,060
static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev) { char *str, *tmp; const char *bootargs; str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path, rootnfsopts[0] ? "," : "", rootnfsopts); /* forward specific mount options on demand */ if (npriv->manual_nfs_port == 1) { tmp = basprintf("%s,port=%hu", str, npriv->nfs_port); free(str); str = tmp; } if (npriv->manual_mount_port == 1) { tmp = basprintf("%s,mountport=%hu", str, npriv->mount_port); free(str); str = tmp; } bootargs = dev_get_param(&npriv->con->edev->dev, "linux.bootargs"); if (bootargs) { tmp = basprintf("%s %s", str, bootargs); free(str); str = tmp; } fsdev_set_linux_rootarg(fsdev, str); free(str); }
Overflow
0
static void nfs_set_rootarg(struct nfs_priv *npriv, struct fs_device_d *fsdev) { char *str, *tmp; const char *bootargs; str = basprintf("root=/dev/nfs nfsroot=%pI4:%s%s%s", &npriv->server, npriv->path, rootnfsopts[0] ? "," : "", rootnfsopts); /* forward specific mount options on demand */ if (npriv->manual_nfs_port == 1) { tmp = basprintf("%s,port=%hu", str, npriv->nfs_port); free(str); str = tmp; } if (npriv->manual_mount_port == 1) { tmp = basprintf("%s,mountport=%hu", str, npriv->mount_port); free(str); str = tmp; } bootargs = dev_get_param(&npriv->con->edev->dev, "linux.bootargs"); if (bootargs) { tmp = basprintf("%s %s", str, bootargs); free(str); str = tmp; } fsdev_set_linux_rootarg(fsdev, str); free(str); }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,061
static int nfs_truncate(struct device_d *dev, FILE *f, loff_t size) { return -ENOSYS; }
Overflow
0
static int nfs_truncate(struct device_d *dev, FILE *f, loff_t size) { return -ENOSYS; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,062
static void nfs_umount_req(struct nfs_priv *npriv) { uint32_t data[1024]; uint32_t *p; int len; int pathlen; struct packet *nfs_packet; pathlen = strlen(npriv->path); p = &(data[0]); p = rpc_add_credentials(p); p = nfs_add_filename(p, pathlen, npriv->path); len = p - &(data[0]); nfs_packet = rpc_req(npriv, PROG_MOUNT, MOUNT_UMOUNT, data, len); if (!IS_ERR(nfs_packet)) free(nfs_packet); }
Overflow
0
static void nfs_umount_req(struct nfs_priv *npriv) { uint32_t data[1024]; uint32_t *p; int len; int pathlen; struct packet *nfs_packet; pathlen = strlen(npriv->path); p = &(data[0]); p = rpc_add_credentials(p); p = nfs_add_filename(p, pathlen, npriv->path); len = p - &(data[0]); nfs_packet = rpc_req(npriv, PROG_MOUNT, MOUNT_UMOUNT, data, len); if (!IS_ERR(nfs_packet)) free(nfs_packet); }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,063
static int nfs_write(struct device_d *_dev, FILE *file, const void *inbuf, size_t insize) { return -ENOSYS; }
Overflow
0
static int nfs_write(struct device_d *_dev, FILE *file, const void *inbuf, size_t insize) { return -ENOSYS; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,064
static inline struct nfs_inode *nfsi(struct inode *inode) { return container_of(inode, struct nfs_inode, inode); }
Overflow
0
static inline struct nfs_inode *nfsi(struct inode *inode) { return container_of(inode, struct nfs_inode, inode); }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,065
static uint32_t *rpc_add_credentials(uint32_t *p) { /* * *BSD refuses AUTH_NONE, so use AUTH_UNIX. An empty hostname is OK for * both Linux and *BSD. */ /* Provide an AUTH_UNIX credential. */ *p++ = hton32(1); /* AUTH_UNIX */ *p++ = hton32(20); /* auth length: 20 + strlen(hostname) */ *p++ = hton32(0); /* stamp */ *p++ = hton32(0); /* hostname string length */ /* memcpy(p, "", 0); p += 0; <- empty host name */ *p++ = 0; /* uid */ *p++ = 0; /* gid */ *p++ = 0; /* auxiliary gid list */ /* Provide an AUTH_NONE verifier. */ *p++ = 0; /* AUTH_NONE */ *p++ = 0; /* auth length */ return p; }
Overflow
0
static uint32_t *rpc_add_credentials(uint32_t *p) { /* * *BSD refuses AUTH_NONE, so use AUTH_UNIX. An empty hostname is OK for * both Linux and *BSD. */ /* Provide an AUTH_UNIX credential. */ *p++ = hton32(1); /* AUTH_UNIX */ *p++ = hton32(20); /* auth length: 20 + strlen(hostname) */ *p++ = hton32(0); /* stamp */ *p++ = hton32(0); /* hostname string length */ /* memcpy(p, "", 0); p += 0; <- empty host name */ *p++ = 0; /* uid */ *p++ = 0; /* gid */ *p++ = 0; /* auxiliary gid list */ /* Provide an AUTH_NONE verifier. */ *p++ = 0; /* AUTH_NONE */ *p++ = 0; /* auth length */ return p; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,066
static int rpc_lookup_req(struct nfs_priv *npriv, uint32_t prog, uint32_t ver) { uint32_t data[16]; struct packet *nfs_packet; uint32_t port; data[0] = 0; data[1] = 0; /* auth credential */ data[2] = 0; data[3] = 0; /* auth verifier */ data[4] = hton32(prog); data[5] = hton32(ver); data[6] = hton32(17); /* IP_UDP */ data[7] = 0; nfs_packet = rpc_req(npriv, PROG_PORTMAP, PORTMAP_GETPORT, data, 8); if (IS_ERR(nfs_packet)) return PTR_ERR(nfs_packet); port = ntoh32(net_read_uint32(nfs_packet->data + sizeof(struct rpc_reply))); free(nfs_packet); return port; }
Overflow
0
static int rpc_lookup_req(struct nfs_priv *npriv, uint32_t prog, uint32_t ver) { uint32_t data[16]; struct packet *nfs_packet; uint32_t port; data[0] = 0; data[1] = 0; /* auth credential */ data[2] = 0; data[3] = 0; /* auth verifier */ data[4] = hton32(prog); data[5] = hton32(ver); data[6] = hton32(17); /* IP_UDP */ data[7] = 0; nfs_packet = rpc_req(npriv, PROG_PORTMAP, PORTMAP_GETPORT, data, 8); if (IS_ERR(nfs_packet)) return PTR_ERR(nfs_packet); port = ntoh32(net_read_uint32(nfs_packet->data + sizeof(struct rpc_reply))); free(nfs_packet); return port; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,067
static void xdr_init(struct xdr_stream *stream, void *buf, int len) { stream->p = stream->buf = buf; stream->end = stream->buf + len; }
Overflow
0
static void xdr_init(struct xdr_stream *stream, void *buf, int len) { stream->p = stream->buf = buf; stream->end = stream->buf + len; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,068
static __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) { __be32 *p; if (nbytes == 0) return xdr->p; if (xdr->p == xdr->end) return NULL; p = __xdr_inline_decode(xdr, nbytes); return p; }
Overflow
0
static __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) { __be32 *p; if (nbytes == 0) return xdr->p; if (xdr->p == xdr->end) return NULL; p = __xdr_inline_decode(xdr, nbytes); return p; }
@@ -1023,6 +1023,10 @@ static int nfs_readlink_req(struct nfs_priv *npriv, struct nfs_fh *fh, p = nfs_read_post_op_attr(p, NULL); len = ntoh32(net_read_uint32(p)); /* new path length */ + + len = max_t(unsigned int, len, + nfs_packet->len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + p++; *target = xzalloc(len + 1);
CWE-119
null
null
1,069
static int nfs_mount_reply(unsigned char *pkt, unsigned len) { int ret; ret = rpc_check_reply(pkt, 1); if (ret) return ret; memcpy(dirfh, pkt + sizeof(struct rpc_reply) + 4, NFS_FHSIZE); return 0; }
Overflow
0
static int nfs_mount_reply(unsigned char *pkt, unsigned len) { int ret; ret = rpc_check_reply(pkt, 1); if (ret) return ret; memcpy(dirfh, pkt + sizeof(struct rpc_reply) + 4, NFS_FHSIZE); return 0; }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,070
static void nfs_read_req(int offset, int readlen) { uint32_t data[1024]; uint32_t *p; int len; p = &(data[0]); p = rpc_add_credentials(p); memcpy (p, filefh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); *p++ = htonl(offset); *p++ = htonl(readlen); *p++ = 0; len = p - &(data[0]); rpc_req(PROG_NFS, NFS_READ, data, len); }
Overflow
0
static void nfs_read_req(int offset, int readlen) { uint32_t data[1024]; uint32_t *p; int len; p = &(data[0]); p = rpc_add_credentials(p); memcpy (p, filefh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); *p++ = htonl(offset); *p++ = htonl(readlen); *p++ = 0; len = p - &(data[0]); rpc_req(PROG_NFS, NFS_READ, data, len); }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,071
static void nfs_readlink_req(void) { uint32_t data[1024]; uint32_t *p; int len; p = &(data[0]); p = rpc_add_credentials(p); memcpy (p, filefh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); len = p - &(data[0]); rpc_req(PROG_NFS, NFS_READLINK, data, len); }
Overflow
0
static void nfs_readlink_req(void) { uint32_t data[1024]; uint32_t *p; int len; p = &(data[0]); p = rpc_add_credentials(p); memcpy (p, filefh, NFS_FHSIZE); p += (NFS_FHSIZE / 4); len = p - &(data[0]); rpc_req(PROG_NFS, NFS_READLINK, data, len); }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,072
static void nfs_send(void) { debug("%s\n", __func__); switch (nfs_state) { case STATE_PRCLOOKUP_PROG_MOUNT_REQ: rpc_lookup_req(PROG_MOUNT, 1); break; case STATE_PRCLOOKUP_PROG_NFS_REQ: rpc_lookup_req(PROG_NFS, 2); break; case STATE_MOUNT_REQ: nfs_mount_req(nfs_path); break; case STATE_UMOUNT_REQ: nfs_umountall_req(); break; case STATE_LOOKUP_REQ: nfs_lookup_req(nfs_filename); break; case STATE_READ_REQ: nfs_read_req(nfs_offset, NFS_READ_SIZE); break; case STATE_READLINK_REQ: nfs_readlink_req(); break; } nfs_timer_start = get_time_ns(); }
Overflow
0
static void nfs_send(void) { debug("%s\n", __func__); switch (nfs_state) { case STATE_PRCLOOKUP_PROG_MOUNT_REQ: rpc_lookup_req(PROG_MOUNT, 1); break; case STATE_PRCLOOKUP_PROG_NFS_REQ: rpc_lookup_req(PROG_NFS, 2); break; case STATE_MOUNT_REQ: nfs_mount_req(nfs_path); break; case STATE_UMOUNT_REQ: nfs_umountall_req(); break; case STATE_LOOKUP_REQ: nfs_lookup_req(nfs_filename); break; case STATE_READ_REQ: nfs_read_req(nfs_offset, NFS_READ_SIZE); break; case STATE_READLINK_REQ: nfs_readlink_req(); break; } nfs_timer_start = get_time_ns(); }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,073
static int nfs_umountall_reply(unsigned char *pkt, unsigned len) { int ret; ret = rpc_check_reply(pkt, 0); if (ret) return ret; memset(dirfh, 0, sizeof(dirfh)); return 0; }
Overflow
0
static int nfs_umountall_reply(unsigned char *pkt, unsigned len) { int ret; ret = rpc_check_reply(pkt, 0); if (ret) return ret; memset(dirfh, 0, sizeof(dirfh)); return 0; }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,074
static void nfs_umountall_req(void) { uint32_t data[1024]; uint32_t *p; int len; if (nfs_server_mount_port < 0) /* Nothing mounted, nothing to umount */ return; p = &(data[0]); p = rpc_add_credentials(p); len = p - &(data[0]); rpc_req(PROG_MOUNT, MOUNT_UMOUNTALL, data, len); }
Overflow
0
static void nfs_umountall_req(void) { uint32_t data[1024]; uint32_t *p; int len; if (nfs_server_mount_port < 0) /* Nothing mounted, nothing to umount */ return; p = &(data[0]); p = rpc_add_credentials(p); len = p - &(data[0]); rpc_req(PROG_MOUNT, MOUNT_UMOUNTALL, data, len); }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,075
static uint32_t *rpc_add_credentials(uint32_t *p) { int hl; int hostnamelen = 0; /* Here's the executive summary on authentication requirements of the * various NFS server implementations: Linux accepts both AUTH_NONE * and AUTH_UNIX authentication (also accepts an empty hostname field * in the AUTH_UNIX scheme). *BSD refuses AUTH_NONE, but accepts * AUTH_UNIX (also accepts an empty hostname field in the AUTH_UNIX * scheme). To be safe, use AUTH_UNIX and pass the hostname if we have * it (if the BOOTP/DHCP reply didn't give one, just use an empty * hostname). */ hl = (hostnamelen + 3) & ~3; /* Provide an AUTH_UNIX credential. */ *p++ = htonl(1); /* AUTH_UNIX */ *p++ = htonl(hl+20); /* auth length */ *p++ = htonl(0); /* stamp */ *p++ = htonl(hostnamelen); /* hostname string */ if (hostnamelen & 3) *(p + hostnamelen / 4) = 0; /* add zero padding */ /* memcpy(p, hostname, hostnamelen); */ /* empty hostname */ p += hl / 4; *p++ = 0; /* uid */ *p++ = 0; /* gid */ *p++ = 0; /* auxiliary gid list */ /* Provide an AUTH_NONE verifier. */ *p++ = 0; /* AUTH_NONE */ *p++ = 0; /* auth length */ return p; }
Overflow
0
static uint32_t *rpc_add_credentials(uint32_t *p) { int hl; int hostnamelen = 0; /* Here's the executive summary on authentication requirements of the * various NFS server implementations: Linux accepts both AUTH_NONE * and AUTH_UNIX authentication (also accepts an empty hostname field * in the AUTH_UNIX scheme). *BSD refuses AUTH_NONE, but accepts * AUTH_UNIX (also accepts an empty hostname field in the AUTH_UNIX * scheme). To be safe, use AUTH_UNIX and pass the hostname if we have * it (if the BOOTP/DHCP reply didn't give one, just use an empty * hostname). */ hl = (hostnamelen + 3) & ~3; /* Provide an AUTH_UNIX credential. */ *p++ = htonl(1); /* AUTH_UNIX */ *p++ = htonl(hl+20); /* auth length */ *p++ = htonl(0); /* stamp */ *p++ = htonl(hostnamelen); /* hostname string */ if (hostnamelen & 3) *(p + hostnamelen / 4) = 0; /* add zero padding */ /* memcpy(p, hostname, hostnamelen); */ /* empty hostname */ p += hl / 4; *p++ = 0; /* uid */ *p++ = 0; /* gid */ *p++ = 0; /* auxiliary gid list */ /* Provide an AUTH_NONE verifier. */ *p++ = 0; /* AUTH_NONE */ *p++ = 0; /* auth length */ return p; }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,076
static int rpc_check_reply(unsigned char *pkt, int isnfs) { uint32_t *data; int nfserr; struct rpc_reply rpc; memcpy(&rpc, pkt, sizeof(rpc)); if (ntohl(rpc.id) != rpc_id) return -EINVAL; if (rpc.rstatus || rpc.verifier || rpc.astatus ) { return -EINVAL; } if (!isnfs) return 0; data = (uint32_t *)(pkt + sizeof(struct rpc_reply)); nfserr = ntohl(net_read_uint32(data)); debug("%s: state: %d, err %d\n", __func__, nfs_state, -nfserr); if (nfserr <= 30) /* These nfs codes correspond with those in errno.h */ return -nfserr; if (nfserr == NFSERR_STALE) return -ESTALE; return -EINVAL; }
Overflow
0
static int rpc_check_reply(unsigned char *pkt, int isnfs) { uint32_t *data; int nfserr; struct rpc_reply rpc; memcpy(&rpc, pkt, sizeof(rpc)); if (ntohl(rpc.id) != rpc_id) return -EINVAL; if (rpc.rstatus || rpc.verifier || rpc.astatus ) { return -EINVAL; } if (!isnfs) return 0; data = (uint32_t *)(pkt + sizeof(struct rpc_reply)); nfserr = ntohl(net_read_uint32(data)); debug("%s: state: %d, err %d\n", __func__, nfs_state, -nfserr); if (nfserr <= 30) /* These nfs codes correspond with those in errno.h */ return -nfserr; if (nfserr == NFSERR_STALE) return -ESTALE; return -EINVAL; }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,077
static int rpc_lookup_reply(int prog, unsigned char *pkt, unsigned len) { uint32_t port; int ret; ret = rpc_check_reply(pkt, 0); if (ret) return ret; port = net_read_uint32((uint32_t *)(pkt + sizeof(struct rpc_reply))); switch (prog) { case PROG_MOUNT: nfs_server_mount_port = ntohl(port); break; case PROG_NFS: nfs_server_nfs_port = ntohl(port); break; } return 0; }
Overflow
0
static int rpc_lookup_reply(int prog, unsigned char *pkt, unsigned len) { uint32_t port; int ret; ret = rpc_check_reply(pkt, 0); if (ret) return ret; port = net_read_uint32((uint32_t *)(pkt + sizeof(struct rpc_reply))); switch (prog) { case PROG_MOUNT: nfs_server_mount_port = ntohl(port); break; case PROG_NFS: nfs_server_nfs_port = ntohl(port); break; } return 0; }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,078
static void rpc_lookup_req(int prog, int ver) { uint32_t data[16]; data[0] = 0; data[1] = 0; /* auth credential */ data[2] = 0; data[3] = 0; /* auth verifier */ data[4] = htonl(prog); data[5] = htonl(ver); data[6] = htonl(17); /* IP_UDP */ data[7] = 0; rpc_req(PROG_PORTMAP, PORTMAP_GETPORT, data, 8); }
Overflow
0
static void rpc_lookup_req(int prog, int ver) { uint32_t data[16]; data[0] = 0; data[1] = 0; /* auth credential */ data[2] = 0; data[3] = 0; /* auth verifier */ data[4] = htonl(prog); data[5] = htonl(ver); data[6] = htonl(17); /* IP_UDP */ data[7] = 0; rpc_req(PROG_PORTMAP, PORTMAP_GETPORT, data, 8); }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,079
static int rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) { struct rpc_call pkt; unsigned long id; int sport; int ret; unsigned char *payload = net_udp_get_payload(nfs_con); id = ++rpc_id; pkt.id = htonl(id); pkt.type = htonl(MSG_CALL); pkt.rpcvers = htonl(2); /* use RPC version 2 */ pkt.prog = htonl(rpc_prog); pkt.vers = htonl(2); /* portmapper is version 2 */ pkt.proc = htonl(rpc_proc); memcpy(payload, &pkt, sizeof(pkt)); memcpy(payload + sizeof(pkt), data, datalen * sizeof(uint32_t)); if (rpc_prog == PROG_PORTMAP) sport = SUNRPC_PORT; else if (rpc_prog == PROG_MOUNT) sport = nfs_server_mount_port; else sport = nfs_server_nfs_port; nfs_con->udp->uh_dport = htons(sport); ret = net_udp_send(nfs_con, sizeof(pkt) + datalen * sizeof(uint32_t)); return ret; }
Overflow
0
static int rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) { struct rpc_call pkt; unsigned long id; int sport; int ret; unsigned char *payload = net_udp_get_payload(nfs_con); id = ++rpc_id; pkt.id = htonl(id); pkt.type = htonl(MSG_CALL); pkt.rpcvers = htonl(2); /* use RPC version 2 */ pkt.prog = htonl(rpc_prog); pkt.vers = htonl(2); /* portmapper is version 2 */ pkt.proc = htonl(rpc_proc); memcpy(payload, &pkt, sizeof(pkt)); memcpy(payload + sizeof(pkt), data, datalen * sizeof(uint32_t)); if (rpc_prog == PROG_PORTMAP) sport = SUNRPC_PORT; else if (rpc_prog == PROG_MOUNT) sport = nfs_server_mount_port; else sport = nfs_server_nfs_port; nfs_con->udp->uh_dport = htons(sport); ret = net_udp_send(nfs_con, sizeof(pkt) + datalen * sizeof(uint32_t)); return ret; }
@@ -502,7 +502,7 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) { uint32_t *data; char *path; - int rlen; + unsigned int rlen; int ret; ret = rpc_check_reply(pkt, 1); @@ -515,6 +515,9 @@ static int nfs_readlink_reply(unsigned char *pkt, unsigned len) rlen = ntohl(net_read_uint32(data)); /* new path length */ + rlen = max_t(unsigned int, rlen, + len - sizeof(struct rpc_reply) - sizeof(uint32_t)); + data++; path = (char *)data;
CWE-119
null
null
1,080
XcursorFileLoadImages (FILE *file, int size) { XcursorFile f; if (!file) return NULL; _XcursorStdioFileInitialize (file, &f); return XcursorXcFileLoadImages (&f, size); }
Overflow
0
XcursorFileLoadImages (FILE *file, int size) { XcursorFile f; if (!file) return NULL; _XcursorStdioFileInitialize (file, &f); return XcursorXcFileLoadImages (&f, size); }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,081
XcursorImagesCreate (int size) { XcursorImages *images; images = malloc (sizeof (XcursorImages) + size * sizeof (XcursorImage *)); if (!images) return NULL; images->nimage = 0; images->images = (XcursorImage **) (images + 1); images->name = NULL; return images; }
Overflow
0
XcursorImagesCreate (int size) { XcursorImages *images; images = malloc (sizeof (XcursorImages) + size * sizeof (XcursorImage *)); if (!images) return NULL; images->nimage = 0; images->images = (XcursorImage **) (images + 1); images->name = NULL; return images; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,082
XcursorImagesDestroy (XcursorImages *images) { int n; if (!images) return; for (n = 0; n < images->nimage; n++) XcursorImageDestroy (images->images[n]); if (images->name) free (images->name); free (images); }
Overflow
0
XcursorImagesDestroy (XcursorImages *images) { int n; if (!images) return; for (n = 0; n < images->nimage; n++) XcursorImageDestroy (images->images[n]); if (images->name) free (images->name); free (images); }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,083
XcursorImagesSetName (XcursorImages *images, const char *name) { char *new; if (!images || !name) return; new = malloc (strlen (name) + 1); if (!new) return; strcpy (new, name); if (images->name) free (images->name); images->name = new; }
Overflow
0
XcursorImagesSetName (XcursorImages *images, const char *name) { char *new; if (!images || !name) return; new = malloc (strlen (name) + 1); if (!new) return; strcpy (new, name); if (images->name) free (images->name); images->name = new; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,084
XcursorLibraryLoadImages (const char *file, const char *theme, int size) { FILE *f = NULL; XcursorImages *images = NULL; if (!file) return NULL; if (theme) f = XcursorScanTheme (theme, file); if (!f) f = XcursorScanTheme ("default", file); if (f) { images = XcursorFileLoadImages (f, size); if (images) XcursorImagesSetName (images, file); fclose (f); } return images; }
Overflow
0
XcursorLibraryLoadImages (const char *file, const char *theme, int size) { FILE *f = NULL; XcursorImages *images = NULL; if (!file) return NULL; if (theme) f = XcursorScanTheme (theme, file); if (!f) f = XcursorScanTheme ("default", file); if (f) { images = XcursorFileLoadImages (f, size); if (images) XcursorImagesSetName (images, file); fclose (f); } return images; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,085
XcursorScanTheme (const char *theme, const char *name) { FILE *f = NULL; char *full; char *dir; const char *path; char *inherits = NULL; const char *i; if (!theme || !name) return NULL; /* * Scan this theme */ for (path = XcursorLibraryPath (); path && f == NULL; path = _XcursorNextPath (path)) { dir = _XcursorBuildThemeDir (path, theme); if (dir) { full = _XcursorBuildFullname (dir, "cursors", name); if (full) { f = fopen (full, "r"); free (full); } if (!f && !inherits) { full = _XcursorBuildFullname (dir, "", "index.theme"); if (full) { inherits = _XcursorThemeInherits (full); free (full); } } free (dir); } } /* * Recurse to scan inherited themes */ for (i = inherits; i && f == NULL; i = _XcursorNextPath (i)) f = XcursorScanTheme (i, name); if (inherits != NULL) free (inherits); return f; }
Overflow
0
XcursorScanTheme (const char *theme, const char *name) { FILE *f = NULL; char *full; char *dir; const char *path; char *inherits = NULL; const char *i; if (!theme || !name) return NULL; /* * Scan this theme */ for (path = XcursorLibraryPath (); path && f == NULL; path = _XcursorNextPath (path)) { dir = _XcursorBuildThemeDir (path, theme); if (dir) { full = _XcursorBuildFullname (dir, "cursors", name); if (full) { f = fopen (full, "r"); free (full); } if (!f && !inherits) { full = _XcursorBuildFullname (dir, "", "index.theme"); if (full) { inherits = _XcursorThemeInherits (full); free (full); } } free (dir); } } /* * Recurse to scan inherited themes */ for (i = inherits; i && f == NULL; i = _XcursorNextPath (i)) f = XcursorScanTheme (i, name); if (inherits != NULL) free (inherits); return f; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,086
XcursorXcFileLoadImages (XcursorFile *file, int size) { XcursorFileHeader *fileHeader; XcursorDim bestSize; int nsize; XcursorImages *images; int n; int toc; if (!file || size < 0) return NULL; fileHeader = _XcursorReadFileHeader (file); if (!fileHeader) return NULL; bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize); if (!bestSize) { _XcursorFileHeaderDestroy (fileHeader); return NULL; } images = XcursorImagesCreate (nsize); if (!images) { _XcursorFileHeaderDestroy (fileHeader); return NULL; } for (n = 0; n < nsize; n++) { toc = _XcursorFindImageToc (fileHeader, bestSize, n); if (toc < 0) break; images->images[images->nimage] = _XcursorReadImage (file, fileHeader, toc); if (!images->images[images->nimage]) break; images->nimage++; } _XcursorFileHeaderDestroy (fileHeader); if (images->nimage != nsize) { XcursorImagesDestroy (images); images = NULL; } return images; }
Overflow
0
XcursorXcFileLoadImages (XcursorFile *file, int size) { XcursorFileHeader *fileHeader; XcursorDim bestSize; int nsize; XcursorImages *images; int n; int toc; if (!file || size < 0) return NULL; fileHeader = _XcursorReadFileHeader (file); if (!fileHeader) return NULL; bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize); if (!bestSize) { _XcursorFileHeaderDestroy (fileHeader); return NULL; } images = XcursorImagesCreate (nsize); if (!images) { _XcursorFileHeaderDestroy (fileHeader); return NULL; } for (n = 0; n < nsize; n++) { toc = _XcursorFindImageToc (fileHeader, bestSize, n); if (toc < 0) break; images->images[images->nimage] = _XcursorReadImage (file, fileHeader, toc); if (!images->images[images->nimage]) break; images->nimage++; } _XcursorFileHeaderDestroy (fileHeader); if (images->nimage != nsize) { XcursorImagesDestroy (images); images = NULL; } return images; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,087
_XcursorAddPathElt (char *path, const char *elt, int len) { int pathlen = strlen (path); /* append / if the path doesn't currently have one */ if (path[0] == '\0' || path[pathlen - 1] != '/') { strcat (path, "/"); pathlen++; } if (len == -1) len = strlen (elt); /* strip leading slashes */ while (len && elt[0] == '/') { elt++; len--; } strncpy (path + pathlen, elt, len); path[pathlen + len] = '\0'; }
Overflow
0
_XcursorAddPathElt (char *path, const char *elt, int len) { int pathlen = strlen (path); /* append / if the path doesn't currently have one */ if (path[0] == '\0' || path[pathlen - 1] != '/') { strcat (path, "/"); pathlen++; } if (len == -1) len = strlen (elt); /* strip leading slashes */ while (len && elt[0] == '/') { elt++; len--; } strncpy (path + pathlen, elt, len); path[pathlen + len] = '\0'; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,088
_XcursorBuildFullname (const char *dir, const char *subdir, const char *file) { char *full; if (!dir || !subdir || !file) return NULL; full = malloc (strlen (dir) + 1 + strlen (subdir) + 1 + strlen (file) + 1); if (!full) return NULL; full[0] = '\0'; _XcursorAddPathElt (full, dir, -1); _XcursorAddPathElt (full, subdir, -1); _XcursorAddPathElt (full, file, -1); return full; }
Overflow
0
_XcursorBuildFullname (const char *dir, const char *subdir, const char *file) { char *full; if (!dir || !subdir || !file) return NULL; full = malloc (strlen (dir) + 1 + strlen (subdir) + 1 + strlen (file) + 1); if (!full) return NULL; full[0] = '\0'; _XcursorAddPathElt (full, dir, -1); _XcursorAddPathElt (full, subdir, -1); _XcursorAddPathElt (full, file, -1); return full; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,089
_XcursorBuildThemeDir (const char *dir, const char *theme) { const char *colon; const char *tcolon; char *full; char *home; int dirlen; int homelen; int themelen; int len; if (!dir || !theme) return NULL; colon = strchr (dir, ':'); if (!colon) colon = dir + strlen (dir); dirlen = colon - dir; tcolon = strchr (theme, ':'); if (!tcolon) tcolon = theme + strlen (theme); themelen = tcolon - theme; home = NULL; homelen = 0; if (*dir == '~') { home = getenv ("HOME"); if (!home) return NULL; homelen = strlen (home); dir++; dirlen--; } /* * add space for any needed directory separators, one per component, * and one for the trailing null */ len = 1 + homelen + 1 + dirlen + 1 + themelen + 1; full = malloc (len); if (!full) return NULL; full[0] = '\0'; if (home) _XcursorAddPathElt (full, home, -1); _XcursorAddPathElt (full, dir, dirlen); _XcursorAddPathElt (full, theme, themelen); return full; }
Overflow
0
_XcursorBuildThemeDir (const char *dir, const char *theme) { const char *colon; const char *tcolon; char *full; char *home; int dirlen; int homelen; int themelen; int len; if (!dir || !theme) return NULL; colon = strchr (dir, ':'); if (!colon) colon = dir + strlen (dir); dirlen = colon - dir; tcolon = strchr (theme, ':'); if (!tcolon) tcolon = theme + strlen (theme); themelen = tcolon - theme; home = NULL; homelen = 0; if (*dir == '~') { home = getenv ("HOME"); if (!home) return NULL; homelen = strlen (home); dir++; dirlen--; } /* * add space for any needed directory separators, one per component, * and one for the trailing null */ len = 1 + homelen + 1 + dirlen + 1 + themelen + 1; full = malloc (len); if (!full) return NULL; full[0] = '\0'; if (home) _XcursorAddPathElt (full, home, -1); _XcursorAddPathElt (full, dir, dirlen); _XcursorAddPathElt (full, theme, themelen); return full; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,090
_XcursorFileHeaderCreate (int ntoc) { XcursorFileHeader *fileHeader; if (ntoc > 0x10000) return NULL; fileHeader = malloc (sizeof (XcursorFileHeader) + ntoc * sizeof (XcursorFileToc)); if (!fileHeader) return NULL; fileHeader->magic = XCURSOR_MAGIC; fileHeader->header = XCURSOR_FILE_HEADER_LEN; fileHeader->version = XCURSOR_FILE_VERSION; fileHeader->ntoc = ntoc; fileHeader->tocs = (XcursorFileToc *) (fileHeader + 1); return fileHeader; }
Overflow
0
_XcursorFileHeaderCreate (int ntoc) { XcursorFileHeader *fileHeader; if (ntoc > 0x10000) return NULL; fileHeader = malloc (sizeof (XcursorFileHeader) + ntoc * sizeof (XcursorFileToc)); if (!fileHeader) return NULL; fileHeader->magic = XCURSOR_MAGIC; fileHeader->header = XCURSOR_FILE_HEADER_LEN; fileHeader->version = XCURSOR_FILE_VERSION; fileHeader->ntoc = ntoc; fileHeader->tocs = (XcursorFileToc *) (fileHeader + 1); return fileHeader; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,091
_XcursorFileReadChunkHeader (XcursorFile *file, XcursorFileHeader *fileHeader, int toc, XcursorChunkHeader *chunkHeader) { if (!file || !fileHeader || !chunkHeader) return XcursorFalse; if (!_XcursorSeekToToc (file, fileHeader, toc)) return XcursorFalse; if (!_XcursorReadUInt (file, &chunkHeader->header)) return XcursorFalse; if (!_XcursorReadUInt (file, &chunkHeader->type)) return XcursorFalse; if (!_XcursorReadUInt (file, &chunkHeader->subtype)) return XcursorFalse; if (!_XcursorReadUInt (file, &chunkHeader->version)) return XcursorFalse; /* sanity check */ if (chunkHeader->type != fileHeader->tocs[toc].type || chunkHeader->subtype != fileHeader->tocs[toc].subtype) return XcursorFalse; return XcursorTrue; }
Overflow
0
_XcursorFileReadChunkHeader (XcursorFile *file, XcursorFileHeader *fileHeader, int toc, XcursorChunkHeader *chunkHeader) { if (!file || !fileHeader || !chunkHeader) return XcursorFalse; if (!_XcursorSeekToToc (file, fileHeader, toc)) return XcursorFalse; if (!_XcursorReadUInt (file, &chunkHeader->header)) return XcursorFalse; if (!_XcursorReadUInt (file, &chunkHeader->type)) return XcursorFalse; if (!_XcursorReadUInt (file, &chunkHeader->subtype)) return XcursorFalse; if (!_XcursorReadUInt (file, &chunkHeader->version)) return XcursorFalse; /* sanity check */ if (chunkHeader->type != fileHeader->tocs[toc].type || chunkHeader->subtype != fileHeader->tocs[toc].subtype) return XcursorFalse; return XcursorTrue; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,092
_XcursorFindBestSize (XcursorFileHeader *fileHeader, XcursorDim size, int *nsizesp) { unsigned int n; int nsizes = 0; XcursorDim bestSize = 0; XcursorDim thisSize; if (!fileHeader || !nsizesp) return 0; for (n = 0; n < fileHeader->ntoc; n++) { if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE) continue; thisSize = fileHeader->tocs[n].subtype; if (!bestSize || dist (thisSize, size) < dist (bestSize, size)) { bestSize = thisSize; nsizes = 1; } else if (thisSize == bestSize) nsizes++; } *nsizesp = nsizes; return bestSize; }
Overflow
0
_XcursorFindBestSize (XcursorFileHeader *fileHeader, XcursorDim size, int *nsizesp) { unsigned int n; int nsizes = 0; XcursorDim bestSize = 0; XcursorDim thisSize; if (!fileHeader || !nsizesp) return 0; for (n = 0; n < fileHeader->ntoc; n++) { if (fileHeader->tocs[n].type != XCURSOR_IMAGE_TYPE) continue; thisSize = fileHeader->tocs[n].subtype; if (!bestSize || dist (thisSize, size) < dist (bestSize, size)) { bestSize = thisSize; nsizes = 1; } else if (thisSize == bestSize) nsizes++; } *nsizesp = nsizes; return bestSize; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,093
_XcursorFindImageToc (XcursorFileHeader *fileHeader, XcursorDim size, int count) { unsigned int toc; XcursorDim thisSize; if (!fileHeader) return 0; for (toc = 0; toc < fileHeader->ntoc; toc++) { if (fileHeader->tocs[toc].type != XCURSOR_IMAGE_TYPE) continue; thisSize = fileHeader->tocs[toc].subtype; if (thisSize != size) continue; if (!count) break; count--; } if (toc == fileHeader->ntoc) return -1; return toc; }
Overflow
0
_XcursorFindImageToc (XcursorFileHeader *fileHeader, XcursorDim size, int count) { unsigned int toc; XcursorDim thisSize; if (!fileHeader) return 0; for (toc = 0; toc < fileHeader->ntoc; toc++) { if (fileHeader->tocs[toc].type != XCURSOR_IMAGE_TYPE) continue; thisSize = fileHeader->tocs[toc].subtype; if (thisSize != size) continue; if (!count) break; count--; } if (toc == fileHeader->ntoc) return -1; return toc; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,094
_XcursorReadFileHeader (XcursorFile *file) { XcursorFileHeader head, *fileHeader; XcursorUInt skip; unsigned int n; if (!file) return NULL; if (!_XcursorReadUInt (file, &head.magic)) return NULL; if (head.magic != XCURSOR_MAGIC) return NULL; if (!_XcursorReadUInt (file, &head.header)) return NULL; if (!_XcursorReadUInt (file, &head.version)) return NULL; if (!_XcursorReadUInt (file, &head.ntoc)) return NULL; skip = head.header - XCURSOR_FILE_HEADER_LEN; if (skip) if ((*file->seek) (file, skip, SEEK_CUR) == EOF) return NULL; fileHeader = _XcursorFileHeaderCreate (head.ntoc); if (!fileHeader) return NULL; fileHeader->magic = head.magic; fileHeader->header = head.header; fileHeader->version = head.version; fileHeader->ntoc = head.ntoc; for (n = 0; n < fileHeader->ntoc; n++) { if (!_XcursorReadUInt (file, &fileHeader->tocs[n].type)) break; if (!_XcursorReadUInt (file, &fileHeader->tocs[n].subtype)) break; if (!_XcursorReadUInt (file, &fileHeader->tocs[n].position)) break; } if (n != fileHeader->ntoc) { _XcursorFileHeaderDestroy (fileHeader); return NULL; } return fileHeader; }
Overflow
0
_XcursorReadFileHeader (XcursorFile *file) { XcursorFileHeader head, *fileHeader; XcursorUInt skip; unsigned int n; if (!file) return NULL; if (!_XcursorReadUInt (file, &head.magic)) return NULL; if (head.magic != XCURSOR_MAGIC) return NULL; if (!_XcursorReadUInt (file, &head.header)) return NULL; if (!_XcursorReadUInt (file, &head.version)) return NULL; if (!_XcursorReadUInt (file, &head.ntoc)) return NULL; skip = head.header - XCURSOR_FILE_HEADER_LEN; if (skip) if ((*file->seek) (file, skip, SEEK_CUR) == EOF) return NULL; fileHeader = _XcursorFileHeaderCreate (head.ntoc); if (!fileHeader) return NULL; fileHeader->magic = head.magic; fileHeader->header = head.header; fileHeader->version = head.version; fileHeader->ntoc = head.ntoc; for (n = 0; n < fileHeader->ntoc; n++) { if (!_XcursorReadUInt (file, &fileHeader->tocs[n].type)) break; if (!_XcursorReadUInt (file, &fileHeader->tocs[n].subtype)) break; if (!_XcursorReadUInt (file, &fileHeader->tocs[n].position)) break; } if (n != fileHeader->ntoc) { _XcursorFileHeaderDestroy (fileHeader); return NULL; } return fileHeader; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,095
_XcursorReadUInt (XcursorFile *file, XcursorUInt *u) { unsigned char bytes[4]; if (!file || !u) return XcursorFalse; if ((*file->read) (file, bytes, 4) != 4) return XcursorFalse; *u = ((bytes[0] << 0) | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24)); return XcursorTrue; }
Overflow
0
_XcursorReadUInt (XcursorFile *file, XcursorUInt *u) { unsigned char bytes[4]; if (!file || !u) return XcursorFalse; if ((*file->read) (file, bytes, 4) != 4) return XcursorFalse; *u = ((bytes[0] << 0) | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24)); return XcursorTrue; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,096
_XcursorSeekToToc (XcursorFile *file, XcursorFileHeader *fileHeader, int toc) { if (!file || !fileHeader || \ (*file->seek) (file, fileHeader->tocs[toc].position, SEEK_SET) == EOF) return XcursorFalse; return XcursorTrue; }
Overflow
0
_XcursorSeekToToc (XcursorFile *file, XcursorFileHeader *fileHeader, int toc) { if (!file || !fileHeader || \ (*file->seek) (file, fileHeader->tocs[toc].position, SEEK_SET) == EOF) return XcursorFalse; return XcursorTrue; }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,097
_XcursorStdioFileRead (XcursorFile *file, unsigned char *buf, int len) { FILE *f = file->closure; return fread (buf, 1, len, f); }
Overflow
0
_XcursorStdioFileRead (XcursorFile *file, unsigned char *buf, int len) { FILE *f = file->closure; return fread (buf, 1, len, f); }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,098
_XcursorStdioFileSeek (XcursorFile *file, long offset, int whence) { FILE *f = file->closure; return fseek (f, offset, whence); }
Overflow
0
_XcursorStdioFileSeek (XcursorFile *file, long offset, int whence) { FILE *f = file->closure; return fseek (f, offset, whence); }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null
1,099
_XcursorStdioFileWrite (XcursorFile *file, unsigned char *buf, int len) { FILE *f = file->closure; return fwrite (buf, 1, len, f); }
Overflow
0
_XcursorStdioFileWrite (XcursorFile *file, unsigned char *buf, int len) { FILE *f = file->closure; return fwrite (buf, 1, len, f); }
@@ -202,6 +202,11 @@ XcursorImageCreate (int width, int height) { XcursorImage *image; + if (width < 0 || height < 0) + return NULL; + if (width > XCURSOR_IMAGE_MAX_SIZE || height > XCURSOR_IMAGE_MAX_SIZE) + return NULL; + image = malloc (sizeof (XcursorImage) + width * height * sizeof (XcursorPixel)); if (!image) @@ -482,7 +487,8 @@ _XcursorReadImage (XcursorFile *file, if (!_XcursorReadUInt (file, &head.delay)) return NULL; /* sanity check data */ - if (head.width >= 0x10000 || head.height > 0x10000) + if (head.width > XCURSOR_IMAGE_MAX_SIZE || + head.height > XCURSOR_IMAGE_MAX_SIZE) return NULL; if (head.width == 0 || head.height == 0) return NULL;
CWE-190
null
null