"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "xpdf/JBIG2Stream.cc" between
xpdf-4.02.tar.gz and xpdf-4.03.tar.gz

About: Xpdf is a PDF viewer for X.

JBIG2Stream.cc  (xpdf-4.02):JBIG2Stream.cc  (xpdf-4.03)
skipping to change at line 1307 skipping to change at line 1307
GBool JBIG2Stream::isBinary(GBool last) { GBool JBIG2Stream::isBinary(GBool last) {
return str->isBinary(gTrue); return str->isBinary(gTrue);
} }
void JBIG2Stream::readSegments() { void JBIG2Stream::readSegments() {
Guint segNum, segFlags, segType, page, segLength; Guint segNum, segFlags, segType, page, segLength;
Guint refFlags, nRefSegs; Guint refFlags, nRefSegs;
Guint *refSegs; Guint *refSegs;
int c1, c2, c3; int c1, c2, c3;
Guint i; Guint i;
GBool done;
done = gFalse; done = gFalse;
while (!done && readULong(&segNum)) { while (!done && readULong(&segNum)) {
// segment header flags // segment header flags
if (!readUByte(&segFlags)) { if (!readUByte(&segFlags)) {
goto eofError1; goto eofError1;
} }
segType = segFlags & 0x3f; segType = segFlags & 0x3f;
skipping to change at line 1726 skipping to change at line 1725
huffDecoder->decodeInt(&dh, huffDHTable); huffDecoder->decodeInt(&dh, huffDHTable);
} else { } else {
arithDecoder->decodeInt(&dh, iadhStats); arithDecoder->decodeInt(&dh, iadhStats);
} }
if ((dh <= 0 && (Guint)-dh >= symHeight) || if ((dh <= 0 && (Guint)-dh >= symHeight) ||
(dh > 0 && (Guint)dh > UINT_MAX - symHeight)) { (dh > 0 && (Guint)dh > UINT_MAX - symHeight)) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Bad delta-height value in JBIG2 symbol dictionary"); "Bad delta-height value in JBIG2 symbol dictionary");
goto syntaxError; goto syntaxError;
} }
// sanity check to avoid extremely long run-times with damaged streams
if (dh > 1000000) {
error(errSyntaxError, getPos(),
"Bogus delta-height value in JBIG2 symbol dictionary");
goto syntaxError;
}
symHeight += dh; symHeight += dh;
symWidth = 0; symWidth = 0;
totalWidth = 0; totalWidth = 0;
j = i; j = i;
// sanity check to avoid extremely long run-times with damaged streams
if (symHeight > 100000) {
error(errSyntaxError, getPos(),
"Bogus symbol height value in JBIG2 symbol dictionary");
goto syntaxError;
}
// read the symbols in this height class // read the symbols in this height class
while (1) { while (1) {
// read the delta width // read the delta width
if (huff) { if (huff) {
if (!huffDecoder->decodeInt(&dw, huffDWTable)) { if (!huffDecoder->decodeInt(&dw, huffDWTable)) {
break; break;
} }
} else { } else {
if (!arithDecoder->decodeInt(&dw, iadwStats)) { if (!arithDecoder->decodeInt(&dw, iadwStats)) {
skipping to change at line 1763 skipping to change at line 1763
"Bad delta-height value in JBIG2 symbol dictionary"); "Bad delta-height value in JBIG2 symbol dictionary");
goto syntaxError; goto syntaxError;
} }
symWidth += dw; symWidth += dw;
if (i >= numNewSyms) { if (i >= numNewSyms) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Too many symbols in JBIG2 symbol dictionary"); "Too many symbols in JBIG2 symbol dictionary");
goto syntaxError; goto syntaxError;
} }
// sanity check to avoid extremely long run-times with damaged streams
if (symWidth > 100000) {
error(errSyntaxError, getPos(),
"Bogus symbol width value in JBIG2 symbol dictionary");
goto syntaxError;
}
// using a collective bitmap, so don't read a bitmap here // using a collective bitmap, so don't read a bitmap here
if (huff && !refAgg) { if (huff && !refAgg) {
symWidths[i] = symWidth; symWidths[i] = symWidth;
totalWidth += symWidth; totalWidth += symWidth;
// refinement/aggregate coding // refinement/aggregate coding
} else if (refAgg) { } else if (refAgg) {
if (huff) { if (huff) {
if (!huffDecoder->decodeInt(&refAggNum, huffAggInstTable)) { if (!huffDecoder->decodeInt(&refAggNum, huffAggInstTable)) {
break; break;
skipping to change at line 1980 skipping to change at line 1987
// region segment info field // region segment info field
if (!readULong(&w) || !readULong(&h) || if (!readULong(&w) || !readULong(&h) ||
!readULong(&x) || !readULong(&y) || !readULong(&x) || !readULong(&y) ||
!readUByte(&segInfoFlags)) { !readUByte(&segInfoFlags)) {
goto eofError; goto eofError;
} }
if (w == 0 || h == 0) { if (w == 0 || h == 0) {
error(errSyntaxError, getPos(), "Bad size in JBIG2 text region segment"); error(errSyntaxError, getPos(), "Bad size in JBIG2 text region segment");
return; return;
} }
// sanity check: if the w/h/x/y values are way out of range, it likely
// indicates a damaged JBIG2 stream
if (w / 10 > pageW || h / 10 > pageH ||
x / 10 > pageW || y / 10 > pageH) {
error(errSyntaxError, getPos(),
"Bad size or position in JBIG2 text region segment");
done = gTrue;
return;
}
extCombOp = segInfoFlags & 7; extCombOp = segInfoFlags & 7;
// rest of the text region header // rest of the text region header
if (!readUWord(&flags)) { if (!readUWord(&flags)) {
goto eofError; goto eofError;
} }
huff = flags & 1; huff = flags & 1;
refine = (flags >> 1) & 1; refine = (flags >> 1) & 1;
logStrips = (flags >> 2) & 3; logStrips = (flags >> 2) & 3;
refCorner = (flags >> 4) & 3; refCorner = (flags >> 4) & 3;
skipping to change at line 2560 skipping to change at line 2576
int atx[4], aty[4]; int atx[4], aty[4];
int gridX, gridY, xx, yy, bit, j; int gridX, gridY, xx, yy, bit, j;
Guint bpp, m, n, i; Guint bpp, m, n, i;
// region segment info field // region segment info field
if (!readULong(&w) || !readULong(&h) || if (!readULong(&w) || !readULong(&h) ||
!readULong(&x) || !readULong(&y) || !readULong(&x) || !readULong(&y) ||
!readUByte(&segInfoFlags)) { !readUByte(&segInfoFlags)) {
goto eofError; goto eofError;
} }
// sanity check: if the w/h/x/y values are way out of range, it likely
// indicates a damaged JBIG2 stream
if (w / 10 > pageW || h / 10 > pageH ||
x / 10 > pageW || y / 10 > pageH) {
error(errSyntaxError, getPos(),
"Bad size or position in JBIG2 halftone region segment");
done = gTrue;
return;
}
extCombOp = segInfoFlags & 7; extCombOp = segInfoFlags & 7;
// rest of the halftone region header // rest of the halftone region header
if (!readUByte(&flags)) { if (!readUByte(&flags)) {
goto eofError; goto eofError;
} }
mmr = flags & 1; mmr = flags & 1;
templ = (flags >> 1) & 3; templ = (flags >> 1) & 3;
enableSkip = (flags >> 3) & 1; enableSkip = (flags >> 3) & 1;
combOp = (flags >> 4) & 7; combOp = (flags >> 4) & 7;
skipping to change at line 2723 skipping to change at line 2748
if (!readULong(&w) || !readULong(&h) || if (!readULong(&w) || !readULong(&h) ||
!readULong(&x) || !readULong(&y) || !readULong(&x) || !readULong(&y) ||
!readUByte(&segInfoFlags)) { !readUByte(&segInfoFlags)) {
goto eofError; goto eofError;
} }
if (w == 0 || h == 0) { if (w == 0 || h == 0) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Bad bitmap size in JBIG2 generic region segment"); "Bad bitmap size in JBIG2 generic region segment");
return; return;
} }
// sanity check: if the w/h/x/y values are way out of range, it likely
// indicates a damaged JBIG2 stream
if (w / 10 > pageW || h / 10 > pageH ||
x / 10 > pageW || y / 10 > pageH) {
error(errSyntaxError, getPos(),
"Bad size or position in JBIG2 generic region segment");
done = gTrue;
return;
}
extCombOp = segInfoFlags & 7; extCombOp = segInfoFlags & 7;
// rest of the generic region segment header // rest of the generic region segment header
if (!readUByte(&flags)) { if (!readUByte(&flags)) {
goto eofError; goto eofError;
} }
mmr = flags & 1; mmr = flags & 1;
templ = (flags >> 1) & 3; templ = (flags >> 1) & 3;
tpgdOn = (flags >> 3) & 1; tpgdOn = (flags >> 3) & 1;
skipping to change at line 3626 skipping to change at line 3660
if (!readULong(&w) || !readULong(&h) || if (!readULong(&w) || !readULong(&h) ||
!readULong(&x) || !readULong(&y) || !readULong(&x) || !readULong(&y) ||
!readUByte(&segInfoFlags)) { !readUByte(&segInfoFlags)) {
goto eofError; goto eofError;
} }
if (w == 0 || h == 0) { if (w == 0 || h == 0) {
error(errSyntaxError, getPos(), error(errSyntaxError, getPos(),
"Bad size in JBIG2 generic refinement region segment"); "Bad size in JBIG2 generic refinement region segment");
return; return;
} }
// sanity check: if the w/h/x/y values are way out of range, it likely
// indicates a damaged JBIG2 stream
if (w / 10 > pageW || h / 10 > pageH ||
x / 10 > pageW || y / 10 > pageH) {
error(errSyntaxError, getPos(),
"Bad size or position in JBIG2 generic refinement region segment");
done = gTrue;
return;
}
extCombOp = segInfoFlags & 7; extCombOp = segInfoFlags & 7;
// rest of the generic refinement region segment header // rest of the generic refinement region segment header
if (!readUByte(&flags)) { if (!readUByte(&flags)) {
goto eofError; goto eofError;
} }
templ = flags & 1; templ = flags & 1;
tpgrOn = (flags >> 1) & 1; tpgrOn = (flags >> 1) & 1;
// AT flags // AT flags
 End of changes. 8 change blocks. 
7 lines changed or deleted 50 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)