diff options
author | Even Rouault <even.rouault@spatialys.com> | 2017-01-11 19:02:49 +0000 |
---|---|---|
committer | Even Rouault <even.rouault@spatialys.com> | 2017-01-11 19:02:49 +0000 |
commit | 33e002a170c001bc44ead91581cce020e92694eb (patch) | |
tree | 770878a0aa577f3684c7a4925141baf2c59458e6 /libtiff | |
parent | 537cd1da1856d734a353511e063f755d77aae927 (diff) | |
download | libtiff-git-33e002a170c001bc44ead91581cce020e92694eb.tar.gz |
* libtiff/tiffiop.h, tif_unix.c, tif_win32.c, tif_vms.c: add _TIFFcalloc()
* libtiff/tif_read.c: TIFFReadBufferSetup(): use _TIFFcalloc() to zero
initialize tif_rawdata.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2651
Diffstat (limited to 'libtiff')
-rw-r--r-- | libtiff/tif_read.c | 6 | ||||
-rw-r--r-- | libtiff/tif_unix.c | 10 | ||||
-rw-r--r-- | libtiff/tif_vms.c | 10 | ||||
-rw-r--r-- | libtiff/tif_win32.c | 10 | ||||
-rw-r--r-- | libtiff/tiffio.h | 3 |
5 files changed, 33 insertions, 6 deletions
diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c index b2edb029..6a8c7daf 100644 --- a/libtiff/tif_read.c +++ b/libtiff/tif_read.c @@ -1,4 +1,4 @@ -/* $Id: tif_read.c,v 1.52 2017-01-11 17:48:11 erouault Exp $ */ +/* $Id: tif_read.c,v 1.53 2017-01-11 19:02:49 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -985,7 +985,9 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size) "Invalid buffer size"); return (0); } - tif->tif_rawdata = (uint8*) _TIFFmalloc(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; } if (tif->tif_rawdata == NULL) { diff --git a/libtiff/tif_unix.c b/libtiff/tif_unix.c index 81e9d665..80c437cf 100644 --- a/libtiff/tif_unix.c +++ b/libtiff/tif_unix.c @@ -1,4 +1,4 @@ -/* $Id: tif_unix.c,v 1.27 2015-08-19 02:31:04 bfriesen Exp $ */ +/* $Id: tif_unix.c,v 1.28 2017-01-11 19:02:49 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -316,6 +316,14 @@ _TIFFmalloc(tmsize_t s) return (malloc((size_t) s)); } +void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz) +{ + if( nmemb == 0 || siz == 0 ) + return ((void *) NULL); + + return calloc((size_t) nmemb, (size_t)siz); +} + void _TIFFfree(void* p) { diff --git a/libtiff/tif_vms.c b/libtiff/tif_vms.c index c49587aa..31b0fd3f 100644 --- a/libtiff/tif_vms.c +++ b/libtiff/tif_vms.c @@ -1,4 +1,4 @@ -/* $Id: tif_vms.c,v 1.13 2015-08-19 02:31:04 bfriesen Exp $ */ +/* $Id: tif_vms.c,v 1.14 2017-01-11 19:02:49 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -270,6 +270,14 @@ _TIFFmalloc(tsize_t s) return (malloc((size_t) s)); } +void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz) +{ + if( nmemb == 0 || siz == 0 ) + return ((void *) NULL); + + return calloc((size_t) nmemb, (size_t)siz); +} + void _TIFFfree(tdata_t p) { diff --git a/libtiff/tif_win32.c b/libtiff/tif_win32.c index 24b824f1..090baed8 100644 --- a/libtiff/tif_win32.c +++ b/libtiff/tif_win32.c @@ -1,4 +1,4 @@ -/* $Id: tif_win32.c,v 1.41 2015-08-23 20:12:44 bfriesen Exp $ */ +/* $Id: tif_win32.c,v 1.42 2017-01-11 19:02:49 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -360,6 +360,14 @@ _TIFFmalloc(tmsize_t s) return (malloc((size_t) s)); } +void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz) +{ + if( nmemb == 0 || siz == 0 ) + return ((void *) NULL); + + return calloc((size_t) nmemb, (size_t)siz); +} + void _TIFFfree(void* p) { diff --git a/libtiff/tiffio.h b/libtiff/tiffio.h index 6e508181..ef61b5c0 100644 --- a/libtiff/tiffio.h +++ b/libtiff/tiffio.h @@ -1,4 +1,4 @@ -/* $Id: tiffio.h,v 1.93 2016-12-17 22:33:11 erouault Exp $ */ +/* $Id: tiffio.h,v 1.94 2017-01-11 19:02:49 erouault Exp $ */ /* * Copyright (c) 1988-1997 Sam Leffler @@ -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); |