Index: third_party/libtiff/tif_pixarlog.c |
diff --git a/third_party/tiff_v403/tif_pixarlog.c b/third_party/libtiff/tif_pixarlog.c |
similarity index 98% |
rename from third_party/tiff_v403/tif_pixarlog.c |
rename to third_party/libtiff/tif_pixarlog.c |
index b30e6d4e9bd2e0f0330882179f2f98dbbe7668ce..b93b4c77f1e50a64cf3c786c5afe0a24a06f8795 100644 |
--- a/third_party/tiff_v403/tif_pixarlog.c |
+++ b/third_party/libtiff/tif_pixarlog.c |
@@ -1,4 +1,4 @@ |
-/* $Id: tif_pixarlog.c,v 1.38 2012-06-21 01:01:53 fwarmerdam Exp $ */ |
+/* $Id: tif_pixarlog.c,v 1.39 2012-12-10 17:27:13 tgl Exp $ */ |
/* |
* Copyright (c) 1996-1997 Sam Leffler |
@@ -23,6 +23,7 @@ |
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
* OF THIS SOFTWARE. |
*/ |
+ |
#include "tiffiop.h" |
#ifdef PIXARLOG_SUPPORT |
@@ -643,6 +644,20 @@ multiply_ms(tmsize_t m1, tmsize_t m2) |
return bytes; |
} |
+static tmsize_t |
+add_ms(tmsize_t m1, tmsize_t m2) |
+{ |
+ tmsize_t bytes = m1 + m2; |
+ |
+ /* if either input is zero, assume overflow already occurred */ |
+ if (m1 == 0 || m2 == 0) |
+ bytes = 0; |
+ else if (bytes <= m1 || bytes <= m2) |
+ bytes = 0; |
+ |
+ return bytes; |
+} |
+ |
static int |
PixarLogFixupTags(TIFF* tif) |
{ |
@@ -670,9 +685,11 @@ PixarLogSetupDecode(TIFF* tif) |
td->td_samplesperpixel : 1); |
tbuf_size = multiply_ms(multiply_ms(multiply_ms(sp->stride, td->td_imagewidth), |
td->td_rowsperstrip), sizeof(uint16)); |
+ /* add one more stride in case input ends mid-stride */ |
+ tbuf_size = add_ms(tbuf_size, sizeof(uint16) * sp->stride); |
if (tbuf_size == 0) |
return (0); /* TODO: this is an error return without error report through TIFFErrorExt */ |
- sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size+sizeof(uint16)*sp->stride); |
+ sp->tbuf = (uint16 *) _TIFFmalloc(tbuf_size); |
if (sp->tbuf == NULL) |
return (0); |
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) |
@@ -905,7 +922,7 @@ PixarLogPreEncode(TIFF* tif, uint16 s) |
we need to simplify this code to reflect a ZLib that is likely updated |
to deal with 8byte memory sizes, though this code will respond |
apropriately even before we simplify it */ |
- sp->stream.avail_out = (uInt)tif->tif_rawdatasize; |
+ sp->stream.avail_out = tif->tif_rawdatasize; |
if ((tmsize_t)sp->stream.avail_out != tif->tif_rawdatasize) |
{ |
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size"); |
@@ -1423,4 +1440,3 @@ bad: |
* fill-column: 78 |
* End: |
*/ |
- |