tools/gif2tiff.c:514: error: Integer Overflow L2
  ([0, +oo] - 1):unsigned32 by call to `TIFFWriteEncodedStrip`.

tools/gif2tiff.c:514:6: Call
512. 	    stripsize = TIFFVStripSize(tif, rowsperstrip);
513. 	}
514. 	if (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0)
          ^
515. 	    break;
516. 	strip++;

libtiff/tif_write.c:183:1: Parameter `tif->tif_dir.td_imagelength`
  181.  * NB: Image length must be setup before writing.
  182.  */
  183. tmsize_t
       ^
  184. TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)
  185. {

tools/gif2tiff.c:514:6: Call
512. 	    stripsize = TIFFVStripSize(tif, rowsperstrip);
513. 	}
514. 	if (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0)
          ^
515. 	    break;
516. 	strip++;

libtiff/tif_write.c:183:1: Parameter `tif->tif_dir.td_rowsperstrip`
  181.  * NB: Image length must be setup before writing.
  182.  */
  183. tmsize_t
       ^
  184. TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)
  185. {

libtiff/tif_write.c:190:7: Call
  188. 	uint16 sample;
  189. 
  190. 	if (!WRITECHECKSTRIPS(tif, module))
             ^
  191. 		return ((tmsize_t) -1);
  192. 	/*

libtiff/tif_write.c:488:1: Parameter `tif->tif_dir.td_rowsperstrip`
    486.  * that important information is not changed.
    487.  */
    488. int
         ^
    489. TIFFWriteCheck(TIFF* tif, int tiles, const char* module)
    490. {

libtiff/tif_write.c:535:46: Call
    533. 		}
    534. 	}
    535. 	if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) {
                                                      ^
    536. 		tif->tif_dir.td_nstrips = 0;
    537. 		TIFFErrorExt(tif->tif_clientdata, module, "No space for %s arrays",

libtiff/tif_write.c:448:1: Parameter `tif->tif_dir.td_rowsperstrip`
      446.     (TIFFFieldSet(tif,f) && (tif)->tif_dir.td_imagelength == 0)
      447. 
      448. int
           ^
      449. TIFFSetupStrips(TIFF* tif)
      450. {

libtiff/tif_write.c:460:29: Call
      458. 		td->td_stripsperimage =
      459. 		    isUnspecified(tif, FIELD_ROWSPERSTRIP) ?
      460. 			td->td_samplesperpixel : TIFFNumberOfStrips(tif);
                                       ^
      461. 	td->td_nstrips = td->td_stripsperimage;
      462. 	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)

libtiff/tif_strip.c:60:1: <LHS trace>
58.  * Compute how many strips are in an image.
59.  */
60. uint32
    ^
61. TIFFNumberOfStrips(TIFF* tif)
62. {

libtiff/tif_strip.c:60:1: Parameter `tif->tif_dir.td_imagelength`
        58.  * Compute how many strips are in an image.
        59.  */
        60. uint32
            ^
        61. TIFFNumberOfStrips(TIFF* tif)
        62. {

libtiff/tif_strip.c:67:7: Binary operation: ([0, +oo] - 1):unsigned32 by call to `TIFFWriteEncodedStrip` 
        65. 
        66. 	nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
        67. 	     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
                  ^
        68. 	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
        69. 		nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel,

uint32
TIFFNumberOfStrips(TIFF* tif)
{
	TIFFDirectory *td = &tif->tif_dir;
	uint32 nstrips;
	nstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :
	     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));
	if (td->td_planarconfig == PLANARCONFIG_SEPARATE)
		nstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel,
		    "TIFFNumberOfStrips");
	return (nstrips);
}
['void\nrasterize(int interleaved, char* mode)\n{\n    register unsigned long row;\n    unsigned char *newras;\n    unsigned char *ras;\n    TIFF *tif;\n    tstrip_t strip;\n    tsize_t stripsize;\n    if ((newras = (unsigned char*) _TIFFmalloc(width*height+EXTRAFUDGE)) == NULL) {\n        fprintf(stderr, "not enough memory for image\\n");\n        return;\n    }\n#define DRAWSEGMENT(offset, step) {\t\t\t\\\n        for (row = offset; row < height; row += step) {\t\\\n            _TIFFmemcpy(newras + row*width, ras, width);\\\n            ras += width;                            \t\\\n        }\t\t\t\t\t\t\\\n    }\n    ras = raster;\n    if (interleaved) {\n        DRAWSEGMENT(0, 8);\n        DRAWSEGMENT(4, 8);\n        DRAWSEGMENT(2, 4);\n        DRAWSEGMENT(1, 2);\n    } else\n        DRAWSEGMENT(0, 1);\n#undef DRAWSEGMENT\n    tif = TIFFOpen(imagename, mode);\n    if (!tif) {\n\tTIFFError(imagename,"Can not open output image");\n\texit(-1);\n    }\n    TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) width);\n    TIFFSetField(tif, TIFFTAG_IMAGELENGTH, (uint32) height);\n    TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE);\n    TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);\n    TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, 1);\n    TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);\n    TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP,\n\trowsperstrip = TIFFDefaultStripSize(tif, rowsperstrip));\n    TIFFSetField(tif, TIFFTAG_COMPRESSION, compression);\n    switch (compression) {\n    case COMPRESSION_LZW:\n    case COMPRESSION_DEFLATE:\n\t    if (predictor != 0)\n\t\t    TIFFSetField(tif, TIFFTAG_PREDICTOR, predictor);\n\t    break;\n    }\n    TIFFSetField(tif, TIFFTAG_COLORMAP, red, green, blue);\n    TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);\n    strip = 0;\n    stripsize = TIFFStripSize(tif);\n    for (row=0; row<height; row += rowsperstrip) {\n\tif (rowsperstrip > height-row) {\n\t    rowsperstrip = height-row;\n\t    stripsize = TIFFVStripSize(tif, rowsperstrip);\n\t}\n\tif (TIFFWriteEncodedStrip(tif, strip, newras+row*width, stripsize) < 0)\n\t    break;\n\tstrip++;\n    }\n    TIFFClose(tif);\n    _TIFFfree(newras);\n}', 'tmsize_t\nTIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc)\n{\n\tstatic const char module[] = "TIFFWriteEncodedStrip";\n\tTIFFDirectory *td = &tif->tif_dir;\n\tuint16 sample;\n\tif (!WRITECHECKSTRIPS(tif, module))\n\t\treturn ((tmsize_t) -1);\n\tif (strip >= td->td_nstrips) {\n\t\tif (td->td_planarconfig == PLANARCONFIG_SEPARATE) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    "Can not grow image by strips when using separate planes");\n\t\t\treturn ((tmsize_t) -1);\n\t\t}\n\t\tif (!TIFFGrowStrips(tif, 1, module))\n\t\t\treturn ((tmsize_t) -1);\n\t\ttd->td_stripsperimage =\n\t\t    TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip);\n\t}\n\tif (!BUFFERCHECK(tif))\n\t\treturn ((tmsize_t) -1);\n        tif->tif_flags |= TIFF_BUF4WRITE;\n\ttif->tif_curstrip = strip;\n\ttif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;\n\tif ((tif->tif_flags & TIFF_CODERSETUP) == 0) {\n\t\tif (!(*tif->tif_setupencode)(tif))\n\t\t\treturn ((tmsize_t) -1);\n\t\ttif->tif_flags |= TIFF_CODERSETUP;\n\t}\n\ttif->tif_rawcc = 0;\n\ttif->tif_rawcp = tif->tif_rawdata;\n\tif( td->td_stripbytecount[strip] > 0 )\n        {\n            tif->tif_curoff = 0;\n        }\n\ttif->tif_flags &= ~TIFF_POSTENCODE;\n\tsample = (uint16)(strip / td->td_stripsperimage);\n\tif (!(*tif->tif_preencode)(tif, sample))\n\t\treturn ((tmsize_t) -1);\n\ttif->tif_postdecode( tif, (uint8*) data, cc );\n\tif (!(*tif->tif_encodestrip)(tif, (uint8*) data, cc, sample))\n\t\treturn (0);\n\tif (!(*tif->tif_postencode)(tif))\n\t\treturn ((tmsize_t) -1);\n\tif (!isFillOrder(tif, td->td_fillorder) &&\n\t    (tif->tif_flags & TIFF_NOBITREV) == 0)\n\t\tTIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc);\n\tif (tif->tif_rawcc > 0 &&\n\t    !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc))\n\t\treturn ((tmsize_t) -1);\n\ttif->tif_rawcc = 0;\n\ttif->tif_rawcp = tif->tif_rawdata;\n\treturn (cc);\n}', 'int\nTIFFWriteCheck(TIFF* tif, int tiles, const char* module)\n{\n\tif (tif->tif_mode == O_RDONLY) {\n\t\tTIFFErrorExt(tif->tif_clientdata, module, "File not open for writing");\n\t\treturn (0);\n\t}\n\tif (tiles ^ isTiled(tif)) {\n\t\tTIFFErrorExt(tif->tif_clientdata, module, tiles ?\n\t\t    "Can not write tiles to a stripped image" :\n\t\t    "Can not write scanlines to a tiled image");\n\t\treturn (0);\n\t}\n        _TIFFFillStriles( tif );\n\tif (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) {\n\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t    "Must set \\"ImageWidth\\" before writing data");\n\t\treturn (0);\n\t}\n\tif (tif->tif_dir.td_samplesperpixel == 1) {\n\t\tif (!TIFFFieldSet(tif, FIELD_PLANARCONFIG))\n                    tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG;\n\t} else {\n\t\tif (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) {\n\t\t\tTIFFErrorExt(tif->tif_clientdata, module,\n\t\t\t    "Must set \\"PlanarConfiguration\\" before writing data");\n\t\t\treturn (0);\n\t\t}\n\t}\n\tif (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) {\n\t\ttif->tif_dir.td_nstrips = 0;\n\t\tTIFFErrorExt(tif->tif_clientdata, module, "No space for %s arrays",\n\t\t    isTiled(tif) ? "tile" : "strip");\n\t\treturn (0);\n\t}\n\tif (isTiled(tif))\n\t{\n\t\ttif->tif_tilesize = TIFFTileSize(tif);\n\t\tif (tif->tif_tilesize == 0)\n\t\t\treturn (0);\n\t}\n\telse\n\t\ttif->tif_tilesize = (tmsize_t)(-1);\n\ttif->tif_scanlinesize = TIFFScanlineSize(tif);\n\tif (tif->tif_scanlinesize == 0)\n\t\treturn (0);\n\ttif->tif_flags |= TIFF_BEENWRITING;\n\treturn (1);\n}', 'int\nTIFFSetupStrips(TIFF* tif)\n{\n\tTIFFDirectory* td = &tif->tif_dir;\n\tif (isTiled(tif))\n\t\ttd->td_stripsperimage =\n\t\t    isUnspecified(tif, FIELD_TILEDIMENSIONS) ?\n\t\t\ttd->td_samplesperpixel : TIFFNumberOfTiles(tif);\n\telse\n\t\ttd->td_stripsperimage =\n\t\t    isUnspecified(tif, FIELD_ROWSPERSTRIP) ?\n\t\t\ttd->td_samplesperpixel : TIFFNumberOfStrips(tif);\n\ttd->td_nstrips = td->td_stripsperimage;\n\tif (td->td_planarconfig == PLANARCONFIG_SEPARATE)\n\t\ttd->td_stripsperimage /= td->td_samplesperpixel;\n\ttd->td_stripoffset = (uint64 *)\n\t    _TIFFmalloc(td->td_nstrips * sizeof (uint64));\n\ttd->td_stripbytecount = (uint64 *)\n\t    _TIFFmalloc(td->td_nstrips * sizeof (uint64));\n\tif (td->td_stripoffset == NULL || td->td_stripbytecount == NULL)\n\t\treturn (0);\n\t_TIFFmemset(td->td_stripoffset, 0, td->td_nstrips*sizeof (uint64));\n\t_TIFFmemset(td->td_stripbytecount, 0, td->td_nstrips*sizeof (uint64));\n\tTIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);\n\tTIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);\n\treturn (1);\n}', 'uint32\nTIFFNumberOfStrips(TIFF* tif)\n{\n\tTIFFDirectory *td = &tif->tif_dir;\n\tuint32 nstrips;\n\tnstrips = (td->td_rowsperstrip == (uint32) -1 ? 1 :\n\t     TIFFhowmany_32(td->td_imagelength, td->td_rowsperstrip));\n\tif (td->td_planarconfig == PLANARCONFIG_SEPARATE)\n\t\tnstrips = _TIFFMultiply32(tif, nstrips, (uint32)td->td_samplesperpixel,\n\t\t    "TIFFNumberOfStrips");\n\treturn (nstrips);\n}']