Skip to content

Commit

Permalink
Add dev patch for two more bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntongzhang committed Sep 1, 2023
1 parent da886bd commit fc0ce8a
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
13 changes: 13 additions & 0 deletions data/libtiff/cve_2016_3186/dev.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- a/tools/gif2tiff.c
+++ b/tools/gif2tiff.c
@@ -350,7 +350,7 @@ readextension(void)
int status = 1;

(void) getc(infile);
- while ((count = getc(infile)) && count <= 255)
+ while ((count = getc(infile)) && count <= 255 && count >=0 )
{
assert(count >= 0);
if (fread(buf, 1, count, infile) != (size_t) count) {
fprintf(stderr, "short read from file %s (%s)\n",

46 changes: 46 additions & 0 deletions data/libtiff/cve_2016_5314/dev.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
diff --git a/ChangeLog b/ChangeLog
index 1b0e5996..dee18813 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-06-28 Even Rouault <even.rouault at spatialys.com>
+
+ * libtiff/tif_pixarlog.c: fix potential buffer write overrun in
+ PixarLogDecode() on corrupted/unexpected images (reported by Mathias Svensson)
+
2016-06-15 Bob Friesenhahn <[email protected]>

* libtiff/libtiff.def: Added _TIFFMultiply32 and _TIFFMultiply64
diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
index 06e8af39..cc486c54 100644
--- a/libtiff/tif_pixarlog.c
+++ b/libtiff/tif_pixarlog.c
@@ -459,6 +459,7 @@ horizontalAccumulate8abgr(uint16 *wp, int n, int stride, unsigned char *op,
typedef struct {
TIFFPredictorState predict;
z_stream stream;
+ tmsize_t tbuf_size; /* only set/used on reading for now */
uint16 *tbuf;
uint16 stride;
int state;
@@ -694,6 +695,7 @@ PixarLogSetupDecode(TIFF* tif)
sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size);
if (sp->tbuf == NULL)
return (0);
+ sp->tbuf_size = tbuf_size;
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
sp->user_datafmt = PixarLogGuessDataFmt(td);
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) {
@@ -783,6 +785,12 @@ PixarLogDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
return (0);
}
+ /* Check that we will not fill more than what was allocated */
+ if (sp->stream.avail_out > sp->tbuf_size)
+ {
+ TIFFErrorExt(tif->tif_clientdata, module, "sp->stream.avail_out > sp->tbuf_size");
+ return (0);
+ }
do {
int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
if (state == Z_STREAM_END) {

0 comments on commit fc0ce8a

Please sign in to comment.