Fix several security bugs in the xpdf parts of teTeX.
o iDefense advisories from 2005-12-05 o CAN-2005-3191, CAN-2005-3192, CAN-2005-3193 - JPX Stream Reader Heap Overflow Vulnerability - DCTStream Baseline Heap Overflow Vulnerability - DCTStream Progressive Heap Overflow - StreamPredictor Heap Overflow Vulnerability Patch provided by xpdf developers. ok sturm@
This commit is contained in:
parent
15299ab459
commit
95069a9e1b
@ -1,11 +1,11 @@
|
||||
# $OpenBSD: Makefile,v 1.37 2005/10/26 20:07:29 bernd Exp $
|
||||
# $OpenBSD: Makefile,v 1.38 2005/12/07 21:04:31 bernd Exp $
|
||||
|
||||
COMMENT= "TeX distribution, executables"
|
||||
COMMENT-fmt= "format files"
|
||||
|
||||
VERSION= 3.0
|
||||
DISTNAME= tetex-base-${VERSION}
|
||||
PKGNAME= teTeX_base-${VERSION}p2
|
||||
PKGNAME= teTeX_base-${VERSION}p3
|
||||
FULLPKGNAME-fmt=teTeX_base-fmt-${VERSION}p0
|
||||
CATEGORIES= print
|
||||
|
||||
|
28
print/teTeX/base/patches/patch-libs_xpdf_xpdf_JPXStream_cc
Normal file
28
print/teTeX/base/patches/patch-libs_xpdf_xpdf_JPXStream_cc
Normal file
@ -0,0 +1,28 @@
|
||||
$OpenBSD: patch-libs_xpdf_xpdf_JPXStream_cc,v 1.1 2005/12/07 21:04:31 bernd Exp $
|
||||
--- libs/xpdf/xpdf/JPXStream.cc.orig Thu Jan 22 02:26:45 2004
|
||||
+++ libs/xpdf/xpdf/JPXStream.cc Wed Dec 7 12:06:35 2005
|
||||
@@ -666,7 +666,7 @@ GBool JPXStream::readCodestream(Guint le
|
||||
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;
|
||||
@@ -701,8 +701,13 @@ GBool JPXStream::readCodestream(Guint le
|
||||
/ img.xTileSize;
|
||||
img.nYTiles = (img.ySize - img.yTileOffset + img.yTileSize - 1)
|
||||
/ img.yTileSize;
|
||||
- img.tiles = (JPXTile *)gmalloc(img.nXTiles * img.nYTiles *
|
||||
- sizeof(JPXTile));
|
||||
+ nTiles = img.nXTiles * img.nYTiles;
|
||||
+ // check for overflow before allocating memory
|
||||
+ if (nTiles == 0 || nTiles / img.nXTiles != img.nYTiles) {
|
||||
+ 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 *)gmalloc(img.nComps *
|
||||
sizeof(JPXTileComp));
|
75
print/teTeX/base/patches/patch-libs_xpdf_xpdf_Stream_cc
Normal file
75
print/teTeX/base/patches/patch-libs_xpdf_xpdf_Stream_cc
Normal file
@ -0,0 +1,75 @@
|
||||
$OpenBSD: patch-libs_xpdf_xpdf_Stream_cc,v 1.1 2005/12/07 21:04:31 bernd Exp $
|
||||
--- libs/xpdf/xpdf/Stream.cc.orig Thu Jan 22 02:26:45 2004
|
||||
+++ libs/xpdf/xpdf/Stream.cc Wed Dec 7 12:06:58 2005
|
||||
@@ -407,18 +407,33 @@ void ImageStream::skipLine() {
|
||||
|
||||
StreamPredictor::StreamPredictor(Stream *strA, int predictorA,
|
||||
int widthA, int nCompsA, int nBitsA) {
|
||||
+ int totalBits;
|
||||
+
|
||||
str = strA;
|
||||
predictor = predictorA;
|
||||
width = widthA;
|
||||
nComps = nCompsA;
|
||||
nBits = nBitsA;
|
||||
+ predLine = NULL;
|
||||
+ ok = gFalse;
|
||||
|
||||
nVals = width * nComps;
|
||||
+ totalBits = nVals * nBits;
|
||||
+ if (totalBits == 0 ||
|
||||
+ (totalBits / nBits) / nComps != width ||
|
||||
+ totalBits + 7 < 0) {
|
||||
+ return;
|
||||
+ }
|
||||
pixBytes = (nComps * nBits + 7) >> 3;
|
||||
- rowBytes = ((nVals * nBits + 7) >> 3) + pixBytes;
|
||||
+ rowBytes = ((totalBits + 7) >> 3) + pixBytes;
|
||||
+ if (rowBytes < 0) {
|
||||
+ return;
|
||||
+ }
|
||||
predLine = (Guchar *)gmalloc(rowBytes);
|
||||
memset(predLine, 0, rowBytes);
|
||||
predIdx = rowBytes;
|
||||
+
|
||||
+ ok = gTrue;
|
||||
}
|
||||
|
||||
StreamPredictor::~StreamPredictor() {
|
||||
@@ -1012,6 +1027,10 @@ LZWStream::LZWStream(Stream *strA, int p
|
||||
FilterStream(strA) {
|
||||
if (predictor != 1) {
|
||||
pred = new StreamPredictor(this, predictor, columns, colors, bits);
|
||||
+ if (!pred->isOk()) {
|
||||
+ delete pred;
|
||||
+ pred = NULL;
|
||||
+ }
|
||||
} else {
|
||||
pred = NULL;
|
||||
}
|
||||
@@ -2897,6 +2916,14 @@ GBool DCTStream::readBaselineSOF() {
|
||||
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 (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;
|
||||
@@ -3255,6 +3282,10 @@ FlateStream::FlateStream(Stream *strA, i
|
||||
FilterStream(strA) {
|
||||
if (predictor != 1) {
|
||||
pred = new StreamPredictor(this, predictor, columns, colors, bits);
|
||||
+ if (!pred->isOk()) {
|
||||
+ delete pred;
|
||||
+ pred = NULL;
|
||||
+ }
|
||||
} else {
|
||||
pred = NULL;
|
||||
}
|
20
print/teTeX/base/patches/patch-libs_xpdf_xpdf_Stream_h
Normal file
20
print/teTeX/base/patches/patch-libs_xpdf_xpdf_Stream_h
Normal file
@ -0,0 +1,20 @@
|
||||
$OpenBSD: patch-libs_xpdf_xpdf_Stream_h,v 1.1 2005/12/07 21:04:31 bernd Exp $
|
||||
--- libs/xpdf/xpdf/Stream.h.orig Thu Jan 22 02:26:45 2004
|
||||
+++ libs/xpdf/xpdf/Stream.h Wed Dec 7 12:07:01 2005
|
||||
@@ -233,6 +233,8 @@ public:
|
||||
|
||||
~StreamPredictor();
|
||||
|
||||
+ GBool isOk() { return ok; }
|
||||
+
|
||||
int lookChar();
|
||||
int getChar();
|
||||
|
||||
@@ -250,6 +252,7 @@ private:
|
||||
int rowBytes; // bytes per line
|
||||
Guchar *predLine; // line buffer
|
||||
int predIdx; // current index in predLine
|
||||
+ GBool ok;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------
|
Loading…
Reference in New Issue
Block a user