tools/tiff2ps.c:2351: error: Buffer Overrun L3
  Offset: [1, +oo] Size: [0, +oo] by call to `PSDataColorContig`.

tools/tiff2ps.c:2351:4: Call
2349. 			fprintf(fd, "%s", RGBcolorimage);
2350. 			PSColorContigPreamble(fd, w, h, 3);
2351. 			PSDataColorContig(fd, tif, w, h, 3);
         ^
2352. 		} else {
2353. 			PSColorSeparatePreamble(fd, w, h, 3);

tools/tiff2ps.c:2437:1: Global `tf_bytesperrow`
  2435. #define	PUTHEX(c,fd)	putc(hex[((c)>>4)&0xf],fd); putc(hex[(c)&0xf],fd)
  2436. 
  2437. void
        ^
  2438. PSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)
  2439. {

tools/tiff2ps.c:2466:4: Call
  2464. 		 */
  2465. 		if (bitspersample == 16 && !HOST_BIGENDIAN) {
  2466. 			PS_FlipBytes(cp, tf_bytesperrow);
           ^
  2467. 		}
  2468. 		if (alpha) {

tools/tiff2ps.c:2137:7: <Offset trace>
2135. 	count--;
2136. 
2137. 	for (i = 0; i < count; i += 2) {
            ^
2138. 		temp = buf[i];
2139. 		buf[i] = buf[i + 1];

tools/tiff2ps.c:2137:7: Assignment
    2135. 	count--;
    2136. 
    2137. 	for (i = 0; i < count; i += 2) {
                ^
    2138. 		temp = buf[i];
    2139. 		buf[i] = buf[i + 1];

tools/tiff2ps.c:2125:1: <Length trace>
2123. 
2124. /* Flip the byte order of buffers with 16 bit samples */
2125. static void
      ^
2126. PS_FlipBytes(unsigned char* buf, tsize_t count)
2127. {

tools/tiff2ps.c:2125:1: Parameter `*buf`
    2123. 
    2124. /* Flip the byte order of buffers with 16 bit samples */
    2125. static void
          ^
    2126. PS_FlipBytes(unsigned char* buf, tsize_t count)
    2127. {

tools/tiff2ps.c:2139:12: Array access: Offset: [1, +oo] Size: [0, +oo] by call to `PSDataColorContig` 
    2137. 	for (i = 0; i < count; i += 2) {
    2138. 		temp = buf[i];
    2139. 		buf[i] = buf[i + 1];
                     ^
    2140. 		buf[i + 1] = temp;
    2141. 	}

static void
PS_FlipBytes(unsigned char* buf, tsize_t count)
{
	int i;
	unsigned char temp;
	if (count <= 0 || bitspersample <= 8) {
		return;
	}
	count--;
	for (i = 0; i < count; i += 2) {
		temp = buf[i];
		buf[i] = buf[i + 1];
		buf[i + 1] = temp;
	}
}
['void\nPSpage(FILE* fd, TIFF* tif, uint32 w, uint32 h)\n{\n\tchar\t*\timageOp = "image";\n\tif ( useImagemask && (bitspersample == 1) )\n\t\timageOp = "imagemask";\n\tif ((level2 || level3) && PS_Lvl2page(fd, tif, w, h))\n\t\treturn;\n\tps_bytesperrow = tf_bytesperrow - (extrasamples * bitspersample / 8)*w;\n\tswitch (photometric) {\n\tcase PHOTOMETRIC_RGB:\n\t\tif (planarconfiguration == PLANARCONFIG_CONTIG) {\n\t\t\tfprintf(fd, "%s", RGBcolorimage);\n\t\t\tPSColorContigPreamble(fd, w, h, 3);\n\t\t\tPSDataColorContig(fd, tif, w, h, 3);\n\t\t} else {\n\t\t\tPSColorSeparatePreamble(fd, w, h, 3);\n\t\t\tPSDataColorSeparate(fd, tif, w, h, 3);\n\t\t}\n\t\tbreak;\n\tcase PHOTOMETRIC_SEPARATED:\n\t\tif (planarconfiguration == PLANARCONFIG_CONTIG) {\n\t\t\tPSColorContigPreamble(fd, w, h, 4);\n\t\t\tPSDataColorContig(fd, tif, w, h, 4);\n\t\t} else {\n\t\t\tPSColorSeparatePreamble(fd, w, h, 4);\n\t\t\tPSDataColorSeparate(fd, tif, w, h, 4);\n\t\t}\n\t\tbreak;\n\tcase PHOTOMETRIC_PALETTE:\n\t\tfprintf(fd, "%s", RGBcolorimage);\n\t\tPhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage");\n\t\tfprintf(fd, "/scanLine %ld string def\\n",\n\t\t    (long) ps_bytesperrow * 3L);\n\t\tfprintf(fd, "%lu %lu 8\\n",\n\t\t    (unsigned long) w, (unsigned long) h);\n\t\tfprintf(fd, "[%lu 0 0 -%lu 0 %lu]\\n",\n\t\t    (unsigned long) w, (unsigned long) h, (unsigned long) h);\n\t\tfprintf(fd, "{currentfile scanLine readhexstring pop} bind\\n");\n\t\tfprintf(fd, "false 3 colorimage\\n");\n\t\tPSDataPalette(fd, tif, w, h);\n\t\tbreak;\n\tcase PHOTOMETRIC_MINISBLACK:\n\tcase PHOTOMETRIC_MINISWHITE:\n\t\tPhotoshopBanner(fd, w, h, 1, 1, imageOp);\n\t\tfprintf(fd, "/scanLine %ld string def\\n",\n\t\t    (long) ps_bytesperrow);\n\t\tfprintf(fd, "%lu %lu %d\\n",\n\t\t    (unsigned long) w, (unsigned long) h, bitspersample);\n\t\tfprintf(fd, "[%lu 0 0 -%lu 0 %lu]\\n",\n\t\t    (unsigned long) w, (unsigned long) h, (unsigned long) h);\n\t\tfprintf(fd,\n\t\t    "{currentfile scanLine readhexstring pop} bind\\n");\n\t\tfprintf(fd, "%s\\n", imageOp);\n\t\tPSDataBW(fd, tif, w, h);\n\t\tbreak;\n\t}\n\tputc(\'\\n\', fd);\n}', 'void\nPSDataColorContig(FILE* fd, TIFF* tif, uint32 w, uint32 h, int nc)\n{\n\tuint32 row;\n\tint breaklen = MAXLINE, es = samplesperpixel - nc;\n\ttsize_t cc;\n\tunsigned char *tf_buf;\n\tunsigned char *cp, c;\n\t(void) w;\n        if( es < 0 )\n        {\n            TIFFError(filename, "Inconsistent value of es: %d (samplesperpixel=%u, nc=%d)", es, samplesperpixel, nc);\n            return;\n        }\n\ttf_buf = (unsigned char *) _TIFFmalloc(tf_bytesperrow);\n\tif (tf_buf == NULL) {\n\t\tTIFFError(filename, "No space for scanline buffer");\n\t\treturn;\n\t}\n\tfor (row = 0; row < h; row++) {\n\t\tif (TIFFReadScanline(tif, tf_buf, row, 0) < 0)\n\t\t\tbreak;\n\t\tcp = tf_buf;\n\t\tif (bitspersample == 16 && !HOST_BIGENDIAN) {\n\t\t\tPS_FlipBytes(cp, tf_bytesperrow);\n\t\t}\n\t\tif (alpha) {\n\t\t\tint adjust;\n\t\t\tcc = 0;\n\t\t\tfor (; (cc + nc) <= tf_bytesperrow; cc += samplesperpixel) {\n\t\t\t\tDOBREAK(breaklen, nc, fd);\n\t\t\t\tadjust = 255 - cp[nc];\n\t\t\t\tswitch (nc) {\n\t\t\t\tcase 4: c = *cp++ + adjust; PUTHEX(c,fd);\n\t\t\t\tcase 3: c = *cp++ + adjust; PUTHEX(c,fd);\n\t\t\t\tcase 2: c = *cp++ + adjust; PUTHEX(c,fd);\n\t\t\t\tcase 1: c = *cp++ + adjust; PUTHEX(c,fd);\n\t\t\t\t}\n\t\t\t\tcp += es;\n\t\t\t}\n\t\t} else {\n\t\t\tcc = 0;\n\t\t\tfor (; (cc + nc) <= tf_bytesperrow; cc += samplesperpixel) {\n\t\t\t\tDOBREAK(breaklen, nc, fd);\n\t\t\t\tswitch (nc) {\n\t\t\t\tcase 4: c = *cp++; PUTHEX(c,fd);\n\t\t\t\tcase 3: c = *cp++; PUTHEX(c,fd);\n\t\t\t\tcase 2: c = *cp++; PUTHEX(c,fd);\n\t\t\t\tcase 1: c = *cp++; PUTHEX(c,fd);\n\t\t\t\t}\n\t\t\t\tcp += es;\n\t\t\t}\n\t\t}\n\t}\n\t_TIFFfree((char *) tf_buf);\n}', 'static void\nPS_FlipBytes(unsigned char* buf, tsize_t count)\n{\n\tint i;\n\tunsigned char temp;\n\tif (count <= 0 || bitspersample <= 8) {\n\t\treturn;\n\t}\n\tcount--;\n\tfor (i = 0; i < count; i += 2) {\n\t\ttemp = buf[i];\n\t\tbuf[i] = buf[i + 1];\n\t\tbuf[i + 1] = temp;\n\t}\n}']