libtiff/tif_jpeg.c:792: error: Integer Overflow L2
  ([1, +oo] - [0, 2147483647]):unsigned64 by call to `JPEGFixupTagsSubsamplingReadWord`.

libtiff/tif_jpeg.c:743:1: Parameter `data->filebytesleft`
741. }
742. 
743. static int
     ^
744. JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data)
745. {

libtiff/tif_jpeg.c:752:9: Call
750. 		while (1)
751. 		{
752. 			if (!JPEGFixupTagsSubsamplingReadByte(data,&m))
             ^
753. 				return(0);
754. 			if (m==255)

libtiff/tif_jpeg.c:855:1: Parameter `data->filebytesleft`
  853. }
  854. 
  855. static int
       ^
  856. JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result)
  857. {

libtiff/tif_jpeg.c:759:9: Call
757. 		while (1)
758. 		{
759. 			if (!JPEGFixupTagsSubsamplingReadByte(data,&m))
             ^
760. 				return(0);
761. 			if (m!=255)

libtiff/tif_jpeg.c:855:1: Parameter `data->filebytesleft`
  853. }
  854. 
  855. static int
       ^
  856. JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result)
  857. {

libtiff/tif_jpeg.c:792:11: Call
790. 				{
791. 					uint16 n;
792. 					if (!JPEGFixupTagsSubsamplingReadWord(data,&n))
               ^
793. 						return(0);
794. 					if (n<2)

libtiff/tif_jpeg.c:885:1: Parameter `data->filebytesleft`
  883. }
  884. 
  885. static int
       ^
  886. JPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result)
  887. {

libtiff/tif_jpeg.c:890:7: Call
  888. 	uint8 ma;
  889. 	uint8 mb;
  890. 	if (!JPEGFixupTagsSubsamplingReadByte(data,&ma))
             ^
  891. 		return(0);
  892. 	if (!JPEGFixupTagsSubsamplingReadByte(data,&mb))

libtiff/tif_jpeg.c:855:1: <LHS trace>
853. }
854. 
855. static int
     ^
856. JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result)
857. {

libtiff/tif_jpeg.c:855:1: Parameter `data->filebytesleft`
    853. }
    854. 
    855. static int
         ^
    856. JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result)
    857. {

libtiff/tif_jpeg.c:872:7: <RHS trace>
870. 			m=(uint32)data->filebytesleft;
871. 		assert(m<0x80000000UL);
872. 		if (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m)
           ^
873. 			return(0);
874. 		data->buffercurrentbyte=data->buffer;

libtiff/tif_jpeg.c:872:7: Unknown value from: non-const function
    870. 			m=(uint32)data->filebytesleft;
    871. 		assert(m<0x80000000UL);
    872. 		if (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m)
               ^
    873. 			return(0);
    874. 		data->buffercurrentbyte=data->buffer;

libtiff/tif_jpeg.c:877:3: Binary operation: ([1, +oo] - [0, 2147483647]):unsigned64 by call to `JPEGFixupTagsSubsamplingReadWord` 
    875. 		data->bufferbytesleft=m;
    876. 		data->fileoffset+=m;
    877. 		data->filebytesleft-=m;
           ^
    878. 	}
    879. 	*result=*data->buffercurrentbyte;

static int
JPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result)
{
	if (data->bufferbytesleft==0)
	{
		uint32 m;
		if (data->filebytesleft==0)
			return(0);
		if (!data->filepositioned)
		{
			TIFFSeekFile(data->tif,data->fileoffset,SEEK_SET);
			data->filepositioned=1;
		}
		m=data->buffersize;
		if ((uint64)m>data->filebytesleft)
			m=(uint32)data->filebytesleft;
		assert(m<0x80000000UL);
		if (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m)
			return(0);
		data->buffercurrentbyte=data->buffer;
		data->bufferbytesleft=m;
		data->fileoffset+=m;
		data->filebytesleft-=m;
	}
	*result=*data->buffercurrentbyte;
	data->buffercurrentbyte++;
	data->bufferbytesleft--;
	return(1);
}
['static int\nJPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data)\n{\n\tstatic const char module[] = "JPEGFixupTagsSubsamplingSec";\n\tuint8 m;\n\twhile (1)\n\t{\n\t\twhile (1)\n\t\t{\n\t\t\tif (!JPEGFixupTagsSubsamplingReadByte(data,&m))\n\t\t\t\treturn(0);\n\t\t\tif (m==255)\n\t\t\t\tbreak;\n\t\t}\n\t\twhile (1)\n\t\t{\n\t\t\tif (!JPEGFixupTagsSubsamplingReadByte(data,&m))\n\t\t\t\treturn(0);\n\t\t\tif (m!=255)\n\t\t\t\tbreak;\n\t\t}\n\t\tswitch (m)\n\t\t{\n\t\t\tcase JPEG_MARKER_SOI:\n\t\t\t\tbreak;\n\t\t\tcase JPEG_MARKER_COM:\n\t\t\tcase JPEG_MARKER_APP0:\n\t\t\tcase JPEG_MARKER_APP0+1:\n\t\t\tcase JPEG_MARKER_APP0+2:\n\t\t\tcase JPEG_MARKER_APP0+3:\n\t\t\tcase JPEG_MARKER_APP0+4:\n\t\t\tcase JPEG_MARKER_APP0+5:\n\t\t\tcase JPEG_MARKER_APP0+6:\n\t\t\tcase JPEG_MARKER_APP0+7:\n\t\t\tcase JPEG_MARKER_APP0+8:\n\t\t\tcase JPEG_MARKER_APP0+9:\n\t\t\tcase JPEG_MARKER_APP0+10:\n\t\t\tcase JPEG_MARKER_APP0+11:\n\t\t\tcase JPEG_MARKER_APP0+12:\n\t\t\tcase JPEG_MARKER_APP0+13:\n\t\t\tcase JPEG_MARKER_APP0+14:\n\t\t\tcase JPEG_MARKER_APP0+15:\n\t\t\tcase JPEG_MARKER_DQT:\n\t\t\tcase JPEG_MARKER_DHT:\n\t\t\tcase JPEG_MARKER_DRI:\n\t\t\t\t{\n\t\t\t\t\tuint16 n;\n\t\t\t\t\tif (!JPEGFixupTagsSubsamplingReadWord(data,&n))\n\t\t\t\t\t\treturn(0);\n\t\t\t\t\tif (n<2)\n\t\t\t\t\t\treturn(0);\n\t\t\t\t\tn-=2;\n\t\t\t\t\tif (n>0)\n\t\t\t\t\t\tJPEGFixupTagsSubsamplingSkip(data,n);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase JPEG_MARKER_SOF0:\n\t\t\t\t{\n\t\t\t\t\tuint16 n;\n\t\t\t\t\tuint16 o;\n\t\t\t\t\tuint8 p;\n\t\t\t\t\tuint8 ph,pv;\n\t\t\t\t\tif (!JPEGFixupTagsSubsamplingReadWord(data,&n))\n\t\t\t\t\t\treturn(0);\n\t\t\t\t\tif (n!=8+data->tif->tif_dir.td_samplesperpixel*3)\n\t\t\t\t\t\treturn(0);\n\t\t\t\t\tJPEGFixupTagsSubsamplingSkip(data,7);\n\t\t\t\t\tif (!JPEGFixupTagsSubsamplingReadByte(data,&p))\n\t\t\t\t\t\treturn(0);\n\t\t\t\t\tph=(p>>4);\n\t\t\t\t\tpv=(p&15);\n\t\t\t\t\tJPEGFixupTagsSubsamplingSkip(data,1);\n\t\t\t\t\tfor (o=1; o<data->tif->tif_dir.td_samplesperpixel; o++)\n\t\t\t\t\t{\n\t\t\t\t\t\tJPEGFixupTagsSubsamplingSkip(data,1);\n\t\t\t\t\t\tif (!JPEGFixupTagsSubsamplingReadByte(data,&p))\n\t\t\t\t\t\t\treturn(0);\n\t\t\t\t\t\tif (p!=0x11)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tTIFFWarningExt(data->tif->tif_clientdata,module,\n\t\t\t\t\t\t\t    "Subsampling values inside JPEG compressed data have no TIFF equivalent, auto-correction of TIFF subsampling values failed");\n\t\t\t\t\t\t\treturn(1);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tJPEGFixupTagsSubsamplingSkip(data,1);\n\t\t\t\t\t}\n\t\t\t\t\tif (((ph!=1)&&(ph!=2)&&(ph!=4))||((pv!=1)&&(pv!=2)&&(pv!=4)))\n\t\t\t\t\t{\n\t\t\t\t\t\tTIFFWarningExt(data->tif->tif_clientdata,module,\n\t\t\t\t\t\t    "Subsampling values inside JPEG compressed data have no TIFF equivalent, auto-correction of TIFF subsampling values failed");\n\t\t\t\t\t\treturn(1);\n\t\t\t\t\t}\n\t\t\t\t\tif ((ph!=data->tif->tif_dir.td_ycbcrsubsampling[0])||(pv!=data->tif->tif_dir.td_ycbcrsubsampling[1]))\n\t\t\t\t\t{\n\t\t\t\t\t\tTIFFWarningExt(data->tif->tif_clientdata,module,\n\t\t\t\t\t\t    "Auto-corrected former TIFF subsampling values [%d,%d] to match subsampling values inside JPEG compressed data [%d,%d]",\n\t\t\t\t\t\t    (int)data->tif->tif_dir.td_ycbcrsubsampling[0],\n\t\t\t\t\t\t    (int)data->tif->tif_dir.td_ycbcrsubsampling[1],\n\t\t\t\t\t\t    (int)ph,(int)pv);\n\t\t\t\t\t\tdata->tif->tif_dir.td_ycbcrsubsampling[0]=ph;\n\t\t\t\t\t\tdata->tif->tif_dir.td_ycbcrsubsampling[1]=pv;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn(1);\n\t\t\tdefault:\n\t\t\t\treturn(0);\n\t\t}\n\t}\n}', 'static int\nJPEGFixupTagsSubsamplingReadByte(struct JPEGFixupTagsSubsamplingData* data, uint8* result)\n{\n\tif (data->bufferbytesleft==0)\n\t{\n\t\tuint32 m;\n\t\tif (data->filebytesleft==0)\n\t\t\treturn(0);\n\t\tif (!data->filepositioned)\n\t\t{\n\t\t\tTIFFSeekFile(data->tif,data->fileoffset,SEEK_SET);\n\t\t\tdata->filepositioned=1;\n\t\t}\n\t\tm=data->buffersize;\n\t\tif ((uint64)m>data->filebytesleft)\n\t\t\tm=(uint32)data->filebytesleft;\n\t\tassert(m<0x80000000UL);\n\t\tif (TIFFReadFile(data->tif,data->buffer,(tmsize_t)m)!=(tmsize_t)m)\n\t\t\treturn(0);\n\t\tdata->buffercurrentbyte=data->buffer;\n\t\tdata->bufferbytesleft=m;\n\t\tdata->fileoffset+=m;\n\t\tdata->filebytesleft-=m;\n\t}\n\t*result=*data->buffercurrentbyte;\n\tdata->buffercurrentbyte++;\n\tdata->bufferbytesleft--;\n\treturn(1);\n}', 'static int\nJPEGFixupTagsSubsamplingReadWord(struct JPEGFixupTagsSubsamplingData* data, uint16* result)\n{\n\tuint8 ma;\n\tuint8 mb;\n\tif (!JPEGFixupTagsSubsamplingReadByte(data,&ma))\n\t\treturn(0);\n\tif (!JPEGFixupTagsSubsamplingReadByte(data,&mb))\n\t\treturn(0);\n\t*result=(ma<<8)|mb;\n\treturn(1);\n}']