Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
Please login to access the resource
home:lrupp
pdftohtml
xpdf-Stream.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File xpdf-Stream.patch of Package pdftohtml
--- xpdf/Stream.cc +++ xpdf/Stream.cc @@ -15,6 +15,7 @@ #include <stdio.h> #include <stdlib.h> #include <stddef.h> +#include <limits.h> #ifndef WIN32 #include <unistd.h> #endif @@ -410,12 +411,32 @@ 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() { @@ -981,6 +1002,10 @@ FilterStream(strA) { if (predictor != 1) { pred = new StreamPredictor(this, predictor, columns, colors, bits); + if (!pred->isOk()) { + delete pred; + pred = NULL; + } } else { pred = NULL; } @@ -1226,6 +1251,10 @@ endOfLine = endOfLineA; byteAlign = byteAlignA; columns = columnsA; + if (columns < 1 || columns >= INT_MAX / sizeof(short)) { + error(-1, "invalid number of columns"); + exit(1); + } rows = rowsA; endOfBlock = endOfBlockA; black = blackA; @@ -2864,6 +2893,13 @@ height = read16(); width = read16(); numComps = str->getChar(); + + if (numComps <= 0 || numComps > 4) { + numComps = 0; + error(getPos(), "Bad number of components in DCT stream"); + return gFalse; + } + if (prec != 8) { error(getPos(), "Bad DCT precision %d", prec); return gFalse; @@ -2890,6 +2926,11 @@ height = read16(); width = read16(); numComps = str->getChar(); + if (numComps <= 0 || numComps > 4) { + numComps = 0; + error(getPos(), "Bad number of components in DCT stream"); + return gFalse; + } if (prec != 8) { error(getPos(), "Bad DCT precision %d", prec); return gFalse; @@ -2912,6 +2953,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"); @@ -2979,12 +3024,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]; @@ -3072,9 +3117,11 @@ do { do { c = str->getChar(); + if(c == EOF) return EOF; } while (c != 0xff); do { c = str->getChar(); + if(c == EOF) return EOF; } while (c == 0xff); } while (c == 0x00); return c; @@ -3182,6 +3229,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/Stream.h +++ xpdf/Stream.h @@ -225,6 +225,8 @@ ~StreamPredictor(); + GBool isOk() { return ok; } + int lookChar(); int getChar(); @@ -242,6 +244,7 @@ int rowBytes; // bytes per line Guchar *predLine; // line buffer int predIdx; // current index in predLine + GBool ok; }; //------------------------------------------------------------------------
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor