summaryrefslogtreecommitdiff
path: root/third_party/libtiff/0022-upstream-patch-0012.patch
blob: ce9b5ebc91a40ec442daab93c8da14728332ffbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
diff --git a/third_party/libtiff/tif_read.c b/third_party/libtiff/tif_read.c
index c25e7e79f..47686a473 100644
--- a/third_party/libtiff/tif_read.c
+++ b/third_party/libtiff/tif_read.c
@@ -983,9 +983,9 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
                                 "Invalid buffer size");
                    return (0);
                }
-               tif->tif_rawdata = (uint8*) _TIFFmalloc(tif->tif_rawdatasize);
-               if (tif->tif_rawdata)
-                       memset(tif->tif_rawdata, 0, tif->tif_rawdatasize);
+               /* Initialize to zero to avoid uninitialized buffers in case of */
+                /* short reads (http://bugzilla.maptools.org/show_bug.cgi?id=2651) */
+               tif->tif_rawdata = (uint8*) _TIFFcalloc(1, tif->tif_rawdatasize);
 
                tif->tif_flags |= TIFF_MYBUFFER;
        }
diff --git a/third_party/libtiff/tiffio.h b/third_party/libtiff/tiffio.h
index dd6c9a429..7d0da761f 100644
--- a/third_party/libtiff/tiffio.h
+++ b/third_party/libtiff/tiffio.h
@@ -293,6 +293,7 @@ extern TIFFCodec* TIFFGetConfiguredCODECs(void);
  */
 
 extern void* _TIFFmalloc(tmsize_t s);
+extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz);
 extern void* _TIFFrealloc(void* p, tmsize_t s);
 extern void _TIFFmemset(void* p, int v, tmsize_t c);
 extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c);