|
|
d00bc4 |
From 7704f4b45c7808a6ea73d4b6684f36124ba37c11 Mon Sep 17 00:00:00 2001
|
|
|
d00bc4 |
From: =?UTF-8?q?Nikola=20Forr=C3=B3?= <nforro@redhat.com>
|
|
|
d00bc4 |
Date: Wed, 12 Jun 2019 13:57:49 +0200
|
|
|
d00bc4 |
Subject: [PATCH] Fix important Covscan defects
|
|
|
d00bc4 |
|
|
|
d00bc4 |
---
|
|
|
d00bc4 |
contrib/addtiffo/tif_ovrcache.c | 1 +
|
|
|
d00bc4 |
contrib/iptcutil/iptcutil.c | 4 +++-
|
|
|
d00bc4 |
libtiff/tif_ojpeg.c | 10 ++++++++++
|
|
|
d00bc4 |
libtiff/tif_open.c | 1 +
|
|
|
d00bc4 |
test/ascii_tag.c | 2 +-
|
|
|
d00bc4 |
test/long_tag.c | 2 +-
|
|
|
d00bc4 |
test/short_tag.c | 2 +-
|
|
|
d00bc4 |
test/strip.c | 2 +-
|
|
|
d00bc4 |
tools/tiff2pdf.c | 2 ++
|
|
|
d00bc4 |
tools/tiffcp.c | 6 +++++-
|
|
|
d00bc4 |
tools/tiffcrop.c | 1 +
|
|
|
d00bc4 |
tools/tiffdither.c | 3 ++-
|
|
|
d00bc4 |
tools/tiffsplit.c | 2 ++
|
|
|
d00bc4 |
13 files changed, 31 insertions(+), 7 deletions(-)
|
|
|
d00bc4 |
|
|
|
d00bc4 |
diff --git a/contrib/addtiffo/tif_ovrcache.c b/contrib/addtiffo/tif_ovrcache.c
|
|
|
d00bc4 |
index 646b534..1d183ab 100644
|
|
|
d00bc4 |
--- a/contrib/addtiffo/tif_ovrcache.c
|
|
|
d00bc4 |
+++ b/contrib/addtiffo/tif_ovrcache.c
|
|
|
d00bc4 |
@@ -110,6 +110,7 @@ TIFFOvrCache *TIFFCreateOvrCache( TIFF *hTIFF, int nDirOffset )
|
|
|
d00bc4 |
TIFFErrorExt( hTIFF->tif_clientdata, hTIFF->tif_name,
|
|
|
d00bc4 |
"Can't allocate memory for overview cache." );
|
|
|
d00bc4 |
/* TODO: use of TIFFError is inconsistent with use of fprintf in addtiffo.c, sort out */
|
|
|
d00bc4 |
+ _TIFFfree( psCache );
|
|
|
d00bc4 |
return NULL;
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
|
|
|
d00bc4 |
diff --git a/contrib/iptcutil/iptcutil.c b/contrib/iptcutil/iptcutil.c
|
|
|
d00bc4 |
index 557a67e..b6be247 100644
|
|
|
d00bc4 |
--- a/contrib/iptcutil/iptcutil.c
|
|
|
d00bc4 |
+++ b/contrib/iptcutil/iptcutil.c
|
|
|
d00bc4 |
@@ -293,8 +293,10 @@ int formatIPTC(FILE *ifile, FILE *ofile)
|
|
|
d00bc4 |
for (tagindx=0; tagindx
|
|
|
d00bc4 |
{
|
|
|
d00bc4 |
c = str[tagindx] = getc(ifile);
|
|
|
d00bc4 |
- if (c == EOF)
|
|
|
d00bc4 |
+ if (c == EOF) {
|
|
|
d00bc4 |
+ free(str);
|
|
|
d00bc4 |
return -1;
|
|
|
d00bc4 |
+ }
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
str[ taglen ] = 0;
|
|
|
d00bc4 |
|
|
|
d00bc4 |
diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
|
|
|
d00bc4 |
index 336d47d..3005dcd 100644
|
|
|
d00bc4 |
--- a/libtiff/tif_ojpeg.c
|
|
|
d00bc4 |
+++ b/libtiff/tif_ojpeg.c
|
|
|
d00bc4 |
@@ -1392,11 +1392,15 @@ OJPEGReadHeaderInfoSecStreamDqt(TIFF* tif)
|
|
|
d00bc4 |
nb[sizeof(uint32)+2]=0;
|
|
|
d00bc4 |
nb[sizeof(uint32)+3]=67;
|
|
|
d00bc4 |
if (OJPEGReadBlock(sp,65,&nb[sizeof(uint32)+4])==0)
|
|
|
d00bc4 |
+ {
|
|
|
d00bc4 |
+ _TIFFfree(nb);
|
|
|
d00bc4 |
return(0);
|
|
|
d00bc4 |
+ }
|
|
|
d00bc4 |
o=nb[sizeof(uint32)+4]&1;;
|
|
|
d00bc4 |
if (3
|
|
|
d00bc4 |
{
|
|
|
d00bc4 |
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DQT marker in JPEG data");
|
|
|
d00bc4 |
+ _TIFFfree(nb);
|
|
|
d00bc4 |
return(0);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
if (sp->qtable[o]!=0)
|
|
|
d00bc4 |
@@ -1446,13 +1450,17 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif)
|
|
|
d00bc4 |
nb[sizeof(uint32)+2]=(m>>8);
|
|
|
d00bc4 |
nb[sizeof(uint32)+3]=(m&255);
|
|
|
d00bc4 |
if (OJPEGReadBlock(sp,m-2,&nb[sizeof(uint32)+4])==0)
|
|
|
d00bc4 |
+ {
|
|
|
d00bc4 |
+ _TIFFfree(nb);
|
|
|
d00bc4 |
return(0);
|
|
|
d00bc4 |
+ }
|
|
|
d00bc4 |
o=nb[sizeof(uint32)+4];
|
|
|
d00bc4 |
if ((o&240)==0)
|
|
|
d00bc4 |
{
|
|
|
d00bc4 |
if (3
|
|
|
d00bc4 |
{
|
|
|
d00bc4 |
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
|
|
d00bc4 |
+ _TIFFfree(nb);
|
|
|
d00bc4 |
return(0);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
if (sp->dctable[o]!=0)
|
|
|
d00bc4 |
@@ -1464,12 +1472,14 @@ OJPEGReadHeaderInfoSecStreamDht(TIFF* tif)
|
|
|
d00bc4 |
if ((o&240)!=16)
|
|
|
d00bc4 |
{
|
|
|
d00bc4 |
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
|
|
d00bc4 |
+ _TIFFfree(nb);
|
|
|
d00bc4 |
return(0);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
o&=15;
|
|
|
d00bc4 |
if (3
|
|
|
d00bc4 |
{
|
|
|
d00bc4 |
TIFFErrorExt(tif->tif_clientdata,module,"Corrupt DHT marker in JPEG data");
|
|
|
d00bc4 |
+ _TIFFfree(nb);
|
|
|
d00bc4 |
return(0);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
if (sp->actable[o]!=0)
|
|
|
d00bc4 |
diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c
|
|
|
d00bc4 |
index 3b3b2ce..7578275 100644
|
|
|
d00bc4 |
--- a/libtiff/tif_open.c
|
|
|
d00bc4 |
+++ b/libtiff/tif_open.c
|
|
|
d00bc4 |
@@ -175,6 +175,7 @@ TIFFClientOpen(
|
|
|
d00bc4 |
if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) {
|
|
|
d00bc4 |
TIFFErrorExt(clientdata, module,
|
|
|
d00bc4 |
"One of the client procedures is NULL pointer.");
|
|
|
d00bc4 |
+ _TIFFfree(tif);
|
|
|
d00bc4 |
goto bad2;
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
tif->tif_readproc = readproc;
|
|
|
d00bc4 |
diff --git a/test/ascii_tag.c b/test/ascii_tag.c
|
|
|
d00bc4 |
index bf81212..0e85c8f 100644
|
|
|
d00bc4 |
--- a/test/ascii_tag.c
|
|
|
d00bc4 |
+++ b/test/ascii_tag.c
|
|
|
d00bc4 |
@@ -125,7 +125,7 @@ main(int argc, char **argv)
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
|
|
|
d00bc4 |
/* Write dummy pixel data. */
|
|
|
d00bc4 |
- if (!TIFFWriteScanline(tif, buf, 0, 0) < 0) {
|
|
|
d00bc4 |
+ if (TIFFWriteScanline(tif, buf, 0, 0) == -1) {
|
|
|
d00bc4 |
fprintf (stderr, "Can't write image data.\n");
|
|
|
d00bc4 |
goto failure;
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
diff --git a/test/long_tag.c b/test/long_tag.c
|
|
|
d00bc4 |
index 256bc8e..e895ee4 100644
|
|
|
d00bc4 |
--- a/test/long_tag.c
|
|
|
d00bc4 |
+++ b/test/long_tag.c
|
|
|
d00bc4 |
@@ -109,7 +109,7 @@ main(int argc, char **argv)
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
|
|
|
d00bc4 |
/* Write dummy pixel data. */
|
|
|
d00bc4 |
- if (!TIFFWriteScanline(tif, buf, 0, 0) < 0) {
|
|
|
d00bc4 |
+ if (TIFFWriteScanline(tif, buf, 0, 0) == -1) {
|
|
|
d00bc4 |
fprintf (stderr, "Can't write image data.\n");
|
|
|
d00bc4 |
goto failure;
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
diff --git a/test/short_tag.c b/test/short_tag.c
|
|
|
d00bc4 |
index 45214e1..c9e0c21 100644
|
|
|
d00bc4 |
--- a/test/short_tag.c
|
|
|
d00bc4 |
+++ b/test/short_tag.c
|
|
|
d00bc4 |
@@ -123,7 +123,7 @@ main(int argc, char **argv)
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
|
|
|
d00bc4 |
/* Write dummy pixel data. */
|
|
|
d00bc4 |
- if (!TIFFWriteScanline(tif, buf, 0, 0) < 0) {
|
|
|
d00bc4 |
+ if (TIFFWriteScanline(tif, buf, 0, 0) == -1) {
|
|
|
d00bc4 |
fprintf (stderr, "Can't write image data.\n");
|
|
|
d00bc4 |
goto failure;
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
diff --git a/test/strip.c b/test/strip.c
|
|
|
d00bc4 |
index df6406e..ab7f5ef 100644
|
|
|
d00bc4 |
--- a/test/strip.c
|
|
|
d00bc4 |
+++ b/test/strip.c
|
|
|
d00bc4 |
@@ -278,7 +278,7 @@ write_scanlines(TIFF *tif, const tdata_t array, const tsize_t size)
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
|
|
|
d00bc4 |
for (offset = 0, row = 0; row < length; offset+=scanlinesize, row++) {
|
|
|
d00bc4 |
- if (TIFFWriteScanline(tif, (char *)array + offset, row, 0) < 0) {
|
|
|
d00bc4 |
+ if (TIFFWriteScanline(tif, (char *)array + offset, row, 0) == -1) {
|
|
|
d00bc4 |
fprintf (stderr,
|
|
|
d00bc4 |
"Can't write image data at row %u.\n", row);
|
|
|
d00bc4 |
return -1;
|
|
|
d00bc4 |
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
|
|
|
d00bc4 |
index ac5d70d..a4ce325 100644
|
|
|
d00bc4 |
--- a/tools/tiff2pdf.c
|
|
|
d00bc4 |
+++ b/tools/tiff2pdf.c
|
|
|
d00bc4 |
@@ -2440,6 +2440,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){
|
|
|
d00bc4 |
t2p->tiff_datasize,
|
|
|
d00bc4 |
TIFFFileName(input));
|
|
|
d00bc4 |
t2p->t2p_error = T2P_ERR_ERROR;
|
|
|
d00bc4 |
+ _TIFFfree(buffer);
|
|
|
d00bc4 |
return(0);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
for(i=0;i
|
|
|
d00bc4 |
@@ -2919,6 +2920,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_
|
|
|
d00bc4 |
t2p->tiff_datasize,
|
|
|
d00bc4 |
TIFFFileName(input));
|
|
|
d00bc4 |
t2p->t2p_error = T2P_ERR_ERROR;
|
|
|
d00bc4 |
+ _TIFFfree(buffer);
|
|
|
d00bc4 |
return(0);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
samplebufferoffset=0;
|
|
|
d00bc4 |
diff --git a/tools/tiffcp.c b/tools/tiffcp.c
|
|
|
d00bc4 |
index 48319fa..a54e65d 100644
|
|
|
d00bc4 |
--- a/tools/tiffcp.c
|
|
|
d00bc4 |
+++ b/tools/tiffcp.c
|
|
|
d00bc4 |
@@ -1191,10 +1191,14 @@ DECLAREreadFunc(readSeparateStripsIntoBuffer)
|
|
|
d00bc4 |
{
|
|
|
d00bc4 |
int status = 1;
|
|
|
d00bc4 |
tsize_t scanlinesize = TIFFScanlineSize(in);
|
|
|
d00bc4 |
- tdata_t scanline = _TIFFmalloc(scanlinesize);
|
|
|
d00bc4 |
+ tdata_t scanline;
|
|
|
d00bc4 |
if (!scanlinesize)
|
|
|
d00bc4 |
return 0;
|
|
|
d00bc4 |
|
|
|
d00bc4 |
+ scanline = _TIFFmalloc(scanlinesize);
|
|
|
d00bc4 |
+ if (!scanline)
|
|
|
d00bc4 |
+ return 0;
|
|
|
d00bc4 |
+
|
|
|
d00bc4 |
(void) imagewidth;
|
|
|
d00bc4 |
if (scanline) {
|
|
|
d00bc4 |
uint8* bufp = (uint8*) buf;
|
|
|
d00bc4 |
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
|
|
|
d00bc4 |
index 7684318..a5d0231 100644
|
|
|
d00bc4 |
--- a/tools/tiffcrop.c
|
|
|
d00bc4 |
+++ b/tools/tiffcrop.c
|
|
|
d00bc4 |
@@ -2576,6 +2576,7 @@ static void dump_info(FILE *dumpfile, int format, char *prefix, char *msg, ...)
|
|
|
d00bc4 |
fprintf(dumpfile, "%s ", prefix);
|
|
|
d00bc4 |
vfprintf(dumpfile, msg, ap);
|
|
|
d00bc4 |
fprintf(dumpfile, "\n");
|
|
|
d00bc4 |
+ va_end(ap);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
|
|
|
d00bc4 |
diff --git a/tools/tiffdither.c b/tools/tiffdither.c
|
|
|
d00bc4 |
index 86160f2..5ceb314 100644
|
|
|
d00bc4 |
--- a/tools/tiffdither.c
|
|
|
d00bc4 |
+++ b/tools/tiffdither.c
|
|
|
d00bc4 |
@@ -77,7 +77,7 @@ fsdither(TIFF* in, TIFF* out)
|
|
|
d00bc4 |
* Get first line
|
|
|
d00bc4 |
*/
|
|
|
d00bc4 |
if (TIFFReadScanline(in, inputline, 0, 0) <= 0)
|
|
|
d00bc4 |
- return;
|
|
|
d00bc4 |
+ goto skip_on_error;
|
|
|
d00bc4 |
inptr = inputline;
|
|
|
d00bc4 |
nextptr = nextline;
|
|
|
d00bc4 |
for (j = 0; j < imagewidth; ++j)
|
|
|
d00bc4 |
@@ -128,6 +128,7 @@ fsdither(TIFF* in, TIFF* out)
|
|
|
d00bc4 |
if (TIFFWriteScanline(out, outline, i-1, 0) < 0)
|
|
|
d00bc4 |
break;
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
+skip_on_error:
|
|
|
d00bc4 |
_TIFFfree(inputline);
|
|
|
d00bc4 |
_TIFFfree(thisline);
|
|
|
d00bc4 |
_TIFFfree(nextline);
|
|
|
d00bc4 |
diff --git a/tools/tiffsplit.c b/tools/tiffsplit.c
|
|
|
d00bc4 |
index 135de2e..03b5558 100644
|
|
|
d00bc4 |
--- a/tools/tiffsplit.c
|
|
|
d00bc4 |
+++ b/tools/tiffsplit.c
|
|
|
d00bc4 |
@@ -239,6 +239,7 @@ cpStrips(TIFF* in, TIFF* out)
|
|
|
d00bc4 |
|
|
|
d00bc4 |
if (!TIFFGetField(in, TIFFTAG_STRIPBYTECOUNTS, &bytecounts)) {
|
|
|
d00bc4 |
fprintf(stderr, "tiffsplit: strip byte counts are missing\n");
|
|
|
d00bc4 |
+ _TIFFfree(buf);
|
|
|
d00bc4 |
return (0);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
for (s = 0; s < ns; s++) {
|
|
|
d00bc4 |
@@ -272,6 +273,7 @@ cpTiles(TIFF* in, TIFF* out)
|
|
|
d00bc4 |
|
|
|
d00bc4 |
if (!TIFFGetField(in, TIFFTAG_TILEBYTECOUNTS, &bytecounts)) {
|
|
|
d00bc4 |
fprintf(stderr, "tiffsplit: tile byte counts are missing\n");
|
|
|
d00bc4 |
+ _TIFFfree(buf);
|
|
|
d00bc4 |
return (0);
|
|
|
d00bc4 |
}
|
|
|
d00bc4 |
for (t = 0; t < nt; t++) {
|
|
|
d00bc4 |
--
|
|
|
d00bc4 |
2.21.0
|
|
|
d00bc4 |
|