summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tiff/tools/tiff2ps.c')
-rw-r--r--tiff/tools/tiff2ps.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/tiff/tools/tiff2ps.c b/tiff/tools/tiff2ps.c
index f1f0b372..5874aba6 100644
--- a/tiff/tools/tiff2ps.c
+++ b/tiff/tools/tiff2ps.c
@@ -1,5 +1,3 @@
-/* $Id: tiff2ps.c,v 1.56 2017-04-27 15:46:22 erouault Exp $ */
-
/*
* Copyright (c) 1988-1997 Sam Leffler
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
@@ -63,7 +61,7 @@
* if not specified on the command line.
* Add new command line option to specify document creator
* as an alterntive to the string "tiff2ps" following model
- * of patch submitted by Thomas Jarosch for specifiying a
+ * of patch submitted by Thomas Jarosch for specifying a
* document title which is also supported now.
*
* 2009-Feb-11
@@ -73,7 +71,7 @@
* or landscape) if -h or -w is specified. Rotation is in
* degrees counterclockwise since that is how Postscript does
* it. The auto opption rotates the image 90 degrees ccw to
- * produce landscape if that is a better fit than portait.
+ * produce landscape if that is a better fit than portrait.
*
* Cleaned up code in TIFF2PS and broke into smaller functions
* to simplify rotations.
@@ -520,7 +518,7 @@ checkImage(TIFF* tif)
"PhotometricInterpretation=YCbCr");
return (0);
}
- /* fall thru... */
+ /* fall through... */
case PHOTOMETRIC_RGB:
if (alpha && bitspersample != 8) {
TIFFError(filename,
@@ -528,7 +526,7 @@ checkImage(TIFF* tif)
bitspersample);
return (0);
}
- /* fall thru... */
+ /* fall through... */
case PHOTOMETRIC_SEPARATED:
case PHOTOMETRIC_PALETTE:
case PHOTOMETRIC_MINISBLACK:
@@ -552,7 +550,7 @@ checkImage(TIFF* tif)
bitspersample = 8;
break;
case PHOTOMETRIC_CIELAB:
- /* fall thru... */
+ /* fall through... */
default:
TIFFError(filename,
"Can not handle image with PhotometricInterpretation=%d",
@@ -684,8 +682,8 @@ isCCITTCompression(TIFF* tif)
static tsize_t tf_bytesperrow;
static tsize_t ps_bytesperrow;
-static tsize_t tf_rowsperstrip;
-static tsize_t tf_numberstrips;
+static uint32 tf_rowsperstrip;
+static uint32 tf_numberstrips;
static char *hex = "0123456789abcdef";
/*
@@ -1800,7 +1798,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
int use_rawdata;
uint32 tile_width, tile_height;
uint16 predictor, minsamplevalue, maxsamplevalue;
- int repeat_count;
+ uint32 repeat_count;
char im_h[64], im_x[64], im_y[64];
char * imageOp = "image";
@@ -1852,7 +1850,7 @@ PS_Lvl2ImageDict(FILE* fd, TIFF* tif, uint32 w, uint32 h)
fputs("{ % exec\n", fd);
if (repeat_count > 1)
- fprintf(fd, "%d { %% repeat\n", repeat_count);
+ fprintf(fd, "%u { %% repeat\n", repeat_count);
/*
* Output filter options and image dictionary.
@@ -2266,7 +2264,7 @@ PS_Lvl2page(FILE* fd, TIFF* tif, uint32 w, uint32 h)
if (alpha) {
int adjust, i, j = 0;
int ncomps = samplesperpixel - extrasamples;
- for (i = 0; i < byte_count; i+=samplesperpixel) {
+ for (i = 0; (i + ncomps) < byte_count; i+=samplesperpixel) {
adjust = 255 - buf_data[i + ncomps];
switch (ncomps) {
case 1:
@@ -2446,9 +2444,9 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)
unsigned char *cp, c;
(void) w;
- if( es <= 0 )
+ if( es < 0 )
{
- TIFFError(filename, "Inconsistent value of es: %d", es);
+ TIFFError(filename, "Inconsistent value of es: %d (samplesperpixel=%u, nc=%d)", es, samplesperpixel, nc);
return;
}
tf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow);
@@ -2470,7 +2468,7 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)
if (alpha) {
int adjust;
cc = 0;
- for (; cc < tf_bytesperrow; cc += samplesperpixel) {
+ for (; (cc + nc) <= tf_bytesperrow; cc += samplesperpixel) {
DOBREAK(breaklen, nc, fd);
/*
* For images with alpha, matte against
@@ -2489,7 +2487,7 @@ PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)
}
} else {
cc = 0;
- for (; cc < tf_bytesperrow; cc += samplesperpixel) {
+ for (; (cc + nc) <= tf_bytesperrow; cc += samplesperpixel) {
DOBREAK(breaklen, nc, fd);
switch (nc) {
case 4: c = *cp++; PUTHEX(c,fd);
@@ -2768,7 +2766,7 @@ PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
bufsize = (uint32) bc[0];
- for ( s = 0; ++s < (tstrip_t)tf_numberstrips; ) {
+ for ( s = 0; ++s < tf_numberstrips; ) {
if ( bc[s] > bufsize )
bufsize = (uint32) bc[s];
}
@@ -2801,7 +2799,7 @@ PSRawDataBW(FILE* fd, TIFF* tif, uint32 w, uint32 h)
}
#endif
- for (s = 0; s < (tstrip_t) tf_numberstrips; s++) {
+ for (s = 0; s < tf_numberstrips; s++) {
cc = TIFFReadRawStrip(tif, s, tf_buf, (tmsize_t) bc[s]);
if (cc < 0) {
TIFFError(filename, "Can't read strip");
@@ -2968,10 +2966,10 @@ tsize_t Ascii85EncodeBlock( uint8 * ascii85_p, unsigned f_eod, const uint8 * raw
for ( ; raw_l > 3; raw_l -= 4 )
{
- val32 = *(++raw_p) << 24;
- val32 += *(++raw_p) << 16;
- val32 += *(++raw_p) << 8;
- val32 += *(++raw_p);
+ val32 = (uint32)*(++raw_p) << 24;
+ val32 += (uint32)*(++raw_p) << 16;
+ val32 += (uint32)*(++raw_p) << 8;
+ val32 += (uint32)*(++raw_p);
if ( val32 == 0 ) /* Special case */
{