From 6ea5da8b13503bc883b19497db5e66e736036987 Mon Sep 17 00:00:00 2001 From: Packit Date: Sep 17 2020 18:32:16 +0000 Subject: Apply patch libtiff-checkbytecount.patch patch_name: libtiff-checkbytecount.patch present_in_specfile: true --- diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c index 9ae856c..de0e7d3 100644 --- a/libtiff/tif_ojpeg.c +++ b/libtiff/tif_ojpeg.c @@ -1920,6 +1920,10 @@ OJPEGReadBufferFill(OJPEGState* sp) sp->in_buffer_file_pos=0; else { + if (sp->tif->tif_dir.td_stripbytecount == 0) { + TIFFErrorExt(sp->tif->tif_clientdata,sp->tif->tif_name,"Strip byte counts are missing"); + return(0); + } sp->in_buffer_file_togo=sp->tif->tif_dir.td_stripbytecount[sp->in_buffer_next_strile]; if (sp->in_buffer_file_togo==0) sp->in_buffer_file_pos=0; diff --git a/tools/tiffsplit.c b/tools/tiffsplit.c index 58288cd..135de2e 100644 --- a/tools/tiffsplit.c +++ b/tools/tiffsplit.c @@ -237,7 +237,10 @@ cpStrips(TIFF* in, TIFF* out) tstrip_t s, ns = TIFFNumberOfStrips(in); uint32 *bytecounts; - TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts); + if (!TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts)) { + fprintf(stderr, "tiffsplit: strip byte counts are missing\n"); + return (0); + } for (s = 0; s < ns; s++) { if (bytecounts[s] > (uint32)bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[s]); @@ -267,7 +270,10 @@ cpTiles(TIFF* in, TIFF* out) ttile_t t, nt = TIFFNumberOfTiles(in); uint32 *bytecounts; - TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts); + if (!TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts)) { + fprintf(stderr, "tiffsplit: tile byte counts are missing\n"); + return (0); + } for (t = 0; t < nt; t++) { if (bytecounts[t] > (uint32) bufsize) { buf = (unsigned char *)_TIFFrealloc(buf, bytecounts[t]);