Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
* libtiff/tiffiop.h, tif_unix.c, tif_win32.c, tif_vms.c: add _TIFFcal…
Browse files Browse the repository at this point in the history
…loc()

* libtiff/tif_read.c: TIFFReadBufferSetup(): use _TIFFcalloc() to zero
initialize tif_rawdata.
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2651
  • Loading branch information
erouault committed Jan 11, 2017
1 parent 1b69de9 commit d603320
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2017-01-11 Even Rouault <even.rouault at spatialys.com>

* 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

2017-01-11 Even Rouault <even.rouault at spatialys.com>

* libtiff/tif_getimage.c: add explicit uint32 cast in putagreytile to
Expand Down
4 changes: 3 additions & 1 deletion libtiff/tif_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions libtiff/tif_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 8 additions & 0 deletions libtiff/tif_vms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
8 changes: 8 additions & 0 deletions libtiff/tif_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions libtiff/tiffio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d603320

Please sign in to comment.