summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@redhat.com>2006-01-11 16:52:58 +0000
committerKristian Høgsberg <krh@redhat.com>2006-01-11 16:52:58 +0000
commitc7ce134fb1dadb46e2b3773d0976ea31da0a046f (patch)
tree60c55bebd62a6376b4c9161e4b6c8aa955e4b0ff
parentec7fb41725c19bc7f2aad1073fe6397ea0a8da0d (diff)
2006-01-11 Kristian Høgsberg <krh@redhat.com>poppler-0.5.0
* poppler/JBIG2Stream.cc: * poppler/Stream.cc: Merge patch to fix CVE-2005-3624, CVE-2005-3625 and CVE-2005-3627 issues.
-rw-r--r--ChangeLog6
-rw-r--r--poppler/JBIG2Stream.cc32
-rw-r--r--poppler/Stream.cc8
3 files changed, 42 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index e921ea53..21bf14c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-01-11 Kristian Høgsberg <krh@redhat.com>
+
+ * poppler/JBIG2Stream.cc:
+ * poppler/Stream.cc: Merge patch to fix CVE-2005-3624,
+ CVE-2005-3625 and CVE-2005-3627 issues.
+
2006-01-10 Albert Astals Cid <aacid@kde.org>
* configure.ac:
diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index f1fcbfa8..337f5ccc 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -13,6 +13,7 @@
#endif
#include <stdlib.h>
+#include <limits.h>
#include "goo/GooList.h"
#include "Error.h"
#include "JArithmeticDecoder.h"
@@ -681,6 +682,12 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, int wA, int hA):
w = wA;
h = hA;
line = (wA + 7) >> 3;
+
+ if (h < 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
+ error(-1, "invalid width/height");
+ data = NULL;
+ return;
+ }
// need to allocate one extra guard byte for use in combine()
data = (Guchar *)gmalloc(h * line + 1);
data[h * line] = 0;
@@ -692,6 +699,12 @@ JBIG2Bitmap::JBIG2Bitmap(Guint segNumA, JBIG2Bitmap *bitmap):
w = bitmap->w;
h = bitmap->h;
line = bitmap->line;
+
+ if (h < 0 || line <= 0 || h >= (INT_MAX - 1) / line) {
+ error(-1, "invalid width/height");
+ data = NULL;
+ return;
+ }
// need to allocate one extra guard byte for use in combine()
data = (Guchar *)gmalloc(h * line + 1);
memcpy(data, bitmap->data, h * line);
@@ -720,7 +733,10 @@ JBIG2Bitmap *JBIG2Bitmap::getSlice(Guint x, Guint y, Guint wA, Guint hA) {
}
void JBIG2Bitmap::expand(int newH, Guint pixel) {
- if (newH <= h) {
+ if (newH <= h || line <= 0 || newH >= (INT_MAX - 1) / line) {
+ error(-1, "invalid width/height");
+ gfree(data);
+ data = NULL;
return;
}
// need to allocate one extra guard byte for use in combine()
@@ -2305,6 +2321,15 @@ void JBIG2Stream::readHalftoneRegionSeg(Guint segNum, GBool imm,
error(getPos(), "Bad symbol dictionary reference in JBIG2 halftone segment");
return;
}
+ if (gridH == 0 || gridW >= INT_MAX / gridH) {
+ error(getPos(), "Bad size in JBIG2 halftone segment");
+ return;
+ }
+ if (w == 0 || h >= INT_MAX / w) {
+ error(getPos(), "Bad size in JBIG2 bitmap segment");
+ return;
+ }
+
patternDict = (JBIG2PatternDict *)seg;
bpp = 0;
i = 1;
@@ -2936,6 +2961,11 @@ JBIG2Bitmap *JBIG2Stream::readGenericRefinementRegion(int w, int h,
JBIG2BitmapPtr tpgrCXPtr0, tpgrCXPtr1, tpgrCXPtr2;
int x, y, pix;
+ if (w < 0 || h <= 0 || w >= INT_MAX / h) {
+ error(-1, "invalid width/height");
+ return NULL;
+ }
+
bitmap = new JBIG2Bitmap(0, w, h);
bitmap->clearToZero();
diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index 7f87bcc0..aa4c769b 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -2930,7 +2930,8 @@ GBool DCTStream::readBaselineSOF() {
width = read16();
numComps = str->getChar();
if (numComps <= 0 || numComps > 4) {
- error(getPos(), "Bad number of components in DCT stream", prec);
+ numComps = 0;
+ error(getPos(), "Bad number of components in DCT stream");
return gFalse;
}
if (prec != 8) {
@@ -2982,6 +2983,7 @@ GBool DCTStream::readScanInfo() {
length = read16() - 2;
scanInfo.numComps = str->getChar();
if (scanInfo.numComps <= 0 || scanInfo.numComps > 4) {
+ scanInfo.numComps = 0;
error(getPos(), "Bad number of components in DCT stream");
return gFalse;
}
@@ -3193,9 +3195,9 @@ int DCTStream::readMarker() {
do {
c = str->getChar();
} while (c != 0xff && c != EOF);
- do {
+ while (c == 0xff) {
c = str->getChar();
- } while (c == 0xff);
+ }
} while (c == 0x00);
return c;
}