summaryrefslogtreecommitdiffstats
path: root/kpdf/xpdf/splash/Splash.cc
diff options
context:
space:
mode:
authorDarrell Anderson <humanreadable@yahoo.com>2012-08-22 13:05:27 -0500
committerSlávek Banko <slavek.banko@axis.cz>2012-08-22 22:36:37 +0200
commit25074c40f0982bf44c4667a6b29fb7ed1d392d2e (patch)
treefa28c8f5daaba699ac4fa1446228ab6ff5631afd /kpdf/xpdf/splash/Splash.cc
parentbe5f9d8e2c5cece0c4cc011ada571da4ea8ce2e1 (diff)
downloadtdegraphics-25074c40f0982bf44c4667a6b29fb7ed1d392d2e.tar.gz
tdegraphics-25074c40f0982bf44c4667a6b29fb7ed1d392d2e.zip
Fix a potential resize bug and apply xpdf 3.02pl4 and 3.02pl5 security patches.
This partially resolves bug report 1175. (cherry picked from commit 561d1d6802dd50ddc9f441442cc2c351dd2759d6)
Diffstat (limited to 'kpdf/xpdf/splash/Splash.cc')
-rw-r--r--kpdf/xpdf/splash/Splash.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/kpdf/xpdf/splash/Splash.cc b/kpdf/xpdf/splash/Splash.cc
index 30179fda..2b91e4e7 100644
--- a/kpdf/xpdf/splash/Splash.cc
+++ b/kpdf/xpdf/splash/Splash.cc
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include "gmem.h"
#include "SplashErrorCodes.h"
#include "SplashMath.h"
@@ -1501,6 +1502,11 @@ SplashError Splash::fillWithPattern(SplashPath *path, GBool eo,
xPath->aaScale();
}
xPath->sort();
+ if (!&xPath->segs[0])
+ {
+ delete xPath;
+ return splashErrEmptyPath;
+ }
scanner = new SplashXPathScanner(xPath, eo);
// get the min and max x and y values
@@ -1937,7 +1943,10 @@ SplashError Splash::fillImageMask(SplashImageMaskSource src, void *srcData,
xq = w % scaledWidth;
// allocate pixel buffer
- pixBuf = (SplashColorPtr)gmalloc((yp + 1) * w);
+ if (yp < 0 || yp > INT_MAX - 1) {
+ return splashErrBadArg;
+ }
+ pixBuf = (SplashColorPtr)gmallocn(yp + 1, w);
// initialize the pixel pipe
pipeInit(&pipe, 0, 0, state->fillPattern, NULL, state->fillAlpha,
@@ -2233,9 +2242,12 @@ SplashError Splash::drawImage(SplashImageSource src, void *srcData,
xq = w % scaledWidth;
// allocate pixel buffers
- colorBuf = (SplashColorPtr)gmalloc((yp + 1) * w * nComps);
+ if (yp < 0 || yp > INT_MAX - 1 || w > INT_MAX / nComps) {
+ return splashErrBadArg;
+ }
+ colorBuf = (SplashColorPtr)gmallocn(yp + 1, w * nComps);
if (srcAlpha) {
- alphaBuf = (Guchar *)gmalloc((yp + 1) * w);
+ alphaBuf = (Guchar *)gmallocn(yp + 1, w);
} else {
alphaBuf = NULL;
}