mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-08-04 02:08:49 -04:00
122 lines
3.1 KiB
Plaintext
122 lines
3.1 KiB
Plaintext
$NetBSD: patch-al,v 1.1 2006/01/24 21:51:36 tron Exp $
|
|
|
|
--- libs/xpdf/xpdf/Stream.cc.orig 2004-01-22 01:26:45.000000000 +0000
|
|
+++ libs/xpdf/xpdf/Stream.cc 2006-01-24 21:37:45.000000000 +0000
|
|
@@ -15,6 +15,7 @@
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stddef.h>
|
|
+#include <limits.h>
|
|
#ifndef WIN32
|
|
#include <unistd.h>
|
|
#endif
|
|
@@ -412,13 +413,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() {
|
|
@@ -1012,6 +1028,10 @@
|
|
FilterStream(strA) {
|
|
if (predictor != 1) {
|
|
pred = new StreamPredictor(this, predictor, columns, colors, bits);
|
|
+ if (!pred->isOk()) {
|
|
+ delete pred;
|
|
+ pred = NULL;
|
|
+ }
|
|
} else {
|
|
pred = NULL;
|
|
}
|
|
@@ -1260,6 +1280,9 @@
|
|
endOfLine = endOfLineA;
|
|
byteAlign = byteAlignA;
|
|
columns = columnsA;
|
|
+ if (columns + 3 < 1 || columns + 4 < 1 || columns < 1) {
|
|
+ columns = 1;
|
|
+ }
|
|
rows = rowsA;
|
|
endOfBlock = endOfBlockA;
|
|
black = blackA;
|
|
@@ -2897,6 +2920,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;
|
|
@@ -2923,6 +2950,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;
|
|
@@ -2945,6 +2976,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");
|
|
@@ -3019,12 +3054,12 @@
|
|
while (length > 0) {
|
|
index = str->getChar();
|
|
--length;
|
|
- if ((index & 0x0f) >= 4) {
|
|
+ if ((index & ~0x10) >= 4 || (index & ~0x10) < 0) {
|
|
error(getPos(), "Bad DCT Huffman table");
|
|
return gFalse;
|
|
}
|
|
if (index & 0x10) {
|
|
- index &= 0x0f;
|
|
+ index &= 0x03;
|
|
if (index >= numACHuffTables)
|
|
numACHuffTables = index+1;
|
|
tbl = &acHuffTables[index];
|
|
@@ -3255,6 +3290,10 @@
|
|
FilterStream(strA) {
|
|
if (predictor != 1) {
|
|
pred = new StreamPredictor(this, predictor, columns, colors, bits);
|
|
+ if (!pred->isOk()) {
|
|
+ delete pred;
|
|
+ pred = NULL;
|
|
+ }
|
|
} else {
|
|
pred = NULL;
|
|
}
|