155 lines
4.4 KiB
Diff
155 lines
4.4 KiB
Diff
|
--- xpdf-3.01/xpdf/Stream.h.cve-2005-3191_2_3 2005-08-16 23:34:31.000000000 -0600
|
||
|
+++ xpdf-3.01/xpdf/Stream.h 2006-01-03 16:06:22.323135129 -0700
|
||
|
@@ -232,6 +232,8 @@
|
||
|
|
||
|
~StreamPredictor();
|
||
|
|
||
|
+ GBool isOk() { return ok; }
|
||
|
+
|
||
|
int lookChar();
|
||
|
int getChar();
|
||
|
|
||
|
@@ -249,6 +251,7 @@
|
||
|
int rowBytes; // bytes per line
|
||
|
Guchar *predLine; // line buffer
|
||
|
int predIdx; // current index in predLine
|
||
|
+ GBool ok;
|
||
|
};
|
||
|
|
||
|
//------------------------------------------------------------------------
|
||
|
--- xpdf-3.01/xpdf/Stream.cc.cve-2005-3191_2_3 2005-08-16 23:34:31.000000000 -0600
|
||
|
+++ xpdf-3.01/xpdf/Stream.cc 2006-01-03 16:06:22.324134948 -0700
|
||
|
@@ -15,6 +15,7 @@
|
||
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <stddef.h>
|
||
|
+#include <limits.h>
|
||
|
#ifndef WIN32
|
||
|
#include <unistd.h>
|
||
|
#endif
|
||
|
@@ -406,13 +407,28 @@
|
||
|
width = widthA;
|
||
|
nComps = nCompsA;
|
||
|
nBits = nBitsA;
|
||
|
+ predLine = NULL;
|
||
|
+ ok = gFalse;
|
||
|
|
||
|
+ if (width <= 0 || nComps <= 0 || nBits <= 0 ||
|
||
|
+ nComps >= INT_MAX/nBits ||
|
||
|
+ width >= INT_MAX/nComps/nBits) {
|
||
|
+ return;
|
||
|
+ }
|
||
|
nVals = width * nComps;
|
||
|
+ if (nVals * nBits + 7 <= 0) {
|
||
|
+ return;
|
||
|
+ }
|
||
|
pixBytes = (nComps * nBits + 7) >> 3;
|
||
|
rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
|
||
|
+ if (rowBytes < 0) {
|
||
|
+ return;
|
||
|
+ }
|
||
|
predLine = (Guchar *)gmalloc(rowBytes);
|
||
|
memset(predLine, 0, rowBytes);
|
||
|
predIdx = rowBytes;
|
||
|
+
|
||
|
+ ok = gTrue;
|
||
|
}
|
||
|
|
||
|
StreamPredictor::~StreamPredictor() {
|
||
|
@@ -1004,6 +1020,10 @@
|
||
|
FilterStream(strA) {
|
||
|
if (predictor != 1) {
|
||
|
pred = new StreamPredictor(this, predictor, columns, colors, bits);
|
||
|
+ if (!pred->isOk()) {
|
||
|
+ delete pred;
|
||
|
+ pred = NULL;
|
||
|
+ }
|
||
|
} else {
|
||
|
pred = NULL;
|
||
|
}
|
||
|
@@ -2899,6 +2919,10 @@
|
||
|
height = read16();
|
||
|
width = read16();
|
||
|
numComps = str->getChar();
|
||
|
+ if (numComps <= 0 || numComps > 4) {
|
||
|
+ error(getPos(), "Bad number of components in DCT stream", prec);
|
||
|
+ return gFalse;
|
||
|
+ }
|
||
|
if (prec != 8) {
|
||
|
error(getPos(), "Bad DCT precision %d", prec);
|
||
|
return gFalse;
|
||
|
@@ -2925,6 +2949,10 @@
|
||
|
height = read16();
|
||
|
width = read16();
|
||
|
numComps = str->getChar();
|
||
|
+ if (numComps <= 0 || numComps > 4) {
|
||
|
+ error(getPos(), "Bad number of components in DCT stream", prec);
|
||
|
+ return gFalse;
|
||
|
+ }
|
||
|
if (prec != 8) {
|
||
|
error(getPos(), "Bad DCT precision %d", prec);
|
||
|
return gFalse;
|
||
|
@@ -2947,6 +2975,10 @@
|
||
|
|
||
|
length = read16() - 2;
|
||
|
scanInfo.numComps = str->getChar();
|
||
|
+ if (scanInfo.numComps <= 0 || scanInfo.numComps > 4) {
|
||
|
+ error(getPos(), "Bad number of components in DCT stream");
|
||
|
+ return gFalse;
|
||
|
+ }
|
||
|
--length;
|
||
|
if (length != 2 * scanInfo.numComps + 3) {
|
||
|
error(getPos(), "Bad DCT scan info block");
|
||
|
@@ -3827,6 +3859,10 @@
|
||
|
FilterStream(strA) {
|
||
|
if (predictor != 1) {
|
||
|
pred = new StreamPredictor(this, predictor, columns, colors, bits);
|
||
|
+ if (!pred->isOk()) {
|
||
|
+ delete pred;
|
||
|
+ pred = NULL;
|
||
|
+ }
|
||
|
} else {
|
||
|
pred = NULL;
|
||
|
}
|
||
|
--- xpdf-3.01/xpdf/JPXStream.cc.cve-2005-3191_2_3 2005-08-16 23:34:31.000000000 -0600
|
||
|
+++ xpdf-3.01/xpdf/JPXStream.cc 2006-01-03 16:10:55.857459404 -0700
|
||
|
@@ -7,6 +7,7 @@
|
||
|
//========================================================================
|
||
|
|
||
|
#include <aconf.h>
|
||
|
+#include <limits.h>
|
||
|
|
||
|
#ifdef USE_GCC_PRAGMAS
|
||
|
#pragma implementation
|
||
|
@@ -783,7 +784,7 @@
|
||
|
int segType;
|
||
|
GBool haveSIZ, haveCOD, haveQCD, haveSOT;
|
||
|
Guint precinctSize, style;
|
||
|
- Guint segLen, capabilities, comp, i, j, r;
|
||
|
+ Guint segLen, capabilities, nTiles, comp, i, j, r;
|
||
|
|
||
|
//----- main header
|
||
|
haveSIZ = haveCOD = haveQCD = haveSOT = gFalse;
|
||
|
@@ -818,8 +819,19 @@
|
||
|
/ img.xTileSize;
|
||
|
img.nYTiles = (img.ySize - img.yTileOffset + img.yTileSize - 1)
|
||
|
/ img.yTileSize;
|
||
|
- img.tiles = (JPXTile *)gmallocn(img.nXTiles * img.nYTiles,
|
||
|
- sizeof(JPXTile));
|
||
|
+ // check for overflow before allocating memory
|
||
|
+ if (img.nXTiles <= 0 || img.nYTiles <= 0 ||
|
||
|
+ img.nXTiles >= INT_MAX/img.nYTiles) {
|
||
|
+ error(getPos(), "Bad tile count in JPX SIZ marker segment");
|
||
|
+ return gFalse;
|
||
|
+ }
|
||
|
+ nTiles = img.nXTiles * img.nYTiles;
|
||
|
+ if (nTiles >= INT_MAX/sizeof(JPXTile)) {
|
||
|
+ error(getPos(), "Bad tile count in JPX SIZ marker segment");
|
||
|
+ return gFalse;
|
||
|
+ }
|
||
|
+ img.tiles = (JPXTile *)gmalloc(nTiles * sizeof(JPXTile));
|
||
|
+
|
||
|
for (i = 0; i < img.nXTiles * img.nYTiles; ++i) {
|
||
|
img.tiles[i].tileComps = (JPXTileComp *)gmallocn(img.nComps,
|
||
|
sizeof(JPXTileComp));
|