diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-11-07 01:32:55 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2021-11-07 01:32:55 +0000 |
commit | 54081f1e108cb4a385f951cbc293368829e39320 (patch) | |
tree | f100ce9b57442d2b57946a93c854fa0b5fbd0463 /converter/pbm/escp2topbm.c | |
parent | 4d5728723616f3713725d85df790666e8d75b963 (diff) | |
download | netpbm-mirror-54081f1e108cb4a385f951cbc293368829e39320.tar.gz netpbm-mirror-54081f1e108cb4a385f951cbc293368829e39320.tar.xz netpbm-mirror-54081f1e108cb4a385f951cbc293368829e39320.zip |
Release 10.96.03
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@4176 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/pbm/escp2topbm.c')
-rw-r--r-- | converter/pbm/escp2topbm.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/converter/pbm/escp2topbm.c b/converter/pbm/escp2topbm.c index 632e6345..8acd13d6 100644 --- a/converter/pbm/escp2topbm.c +++ b/converter/pbm/escp2topbm.c @@ -47,10 +47,17 @@ #include <stdbool.h> +#include <assert.h> #include "mallocvar.h" #include "pbm.h" +static unsigned int widthMax = 127 * 256 + 255; + /* Limit in official Epson manual */ + +static unsigned int const heightMax = 5120 * 200; + /* 5120 rows is sufficient for US legal at 360 DPI */ + #define ESC 033 @@ -120,6 +127,10 @@ readStripeHeader(unsigned int * const widthThisStripeP, pm_error("Error: Abnormal value in data block header: " "Says stripe has zero width or height"); + if (widthThisStripe > widthMax) + pm_error("Error: Abnormal width value in data block header: %u", + widthThisStripe); + if (compression != 0 && compression != 1) pm_error("Error: Unknown compression mode %u", compression); @@ -221,12 +232,10 @@ expandBitarray(unsigned char *** const bitarrayP, unsigned int * const bitarraySizeP) { unsigned int const heightIncrement = 5120; - unsigned int const heightMax = 5120 * 200; - /* 5120 rows is sufficient for US legal at 360 DPI */ *bitarraySizeP += heightIncrement; if (*bitarraySizeP > heightMax) - pm_error("Image too tall"); + pm_error("Error: Image too tall"); else REALLOCARRAY_NOFAIL(*bitarrayP, *bitarraySizeP); } @@ -326,6 +335,10 @@ main(int argc, width, widthThisStripe); } height += rowsThisStripe; + assert(height <= INT_MAX - 10); + /* Becuse image height is tested in expandBitarray() + with a more stringent condition. + */ if (height > bitarraySize) expandBitarray(&bitarray, &bitarraySize); |