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

Commit

Permalink
* libtiff/tif_dirread.c: in TIFFFetchNormalTag(), make sure that
Browse files Browse the repository at this point in the history
values of tags with TIFF_SETGET_C16_ASCII / TIFF_SETGET_C32_ASCII
access are null terminated, to avoid potential read outside buffer
in _TIFFPrintField().
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2590
  • Loading branch information
erouault committed Nov 11, 2016
1 parent 35fc319 commit 30c9234
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
@@ -1,3 +1,11 @@
2016-11-11 Even Rouault <even.rouault at spatialys.com>

* libtiff/tif_dirread.c: in TIFFFetchNormalTag(), make sure that
values of tags with TIFF_SETGET_C16_ASCII / TIFF_SETGET_C32_ASCII
access are null terminated, to avoid potential read outside buffer
in _TIFFPrintField().
Fixes http://bugzilla.maptools.org/show_bug.cgi?id=2590

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


* libtiff/tif_dirread.c: reject images with OJPEG compression that * libtiff/tif_dirread.c: reject images with OJPEG compression that
Expand Down
10 changes: 10 additions & 0 deletions libtiff/tif_dirread.c
Expand Up @@ -5000,6 +5000,11 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
if (err==TIFFReadDirEntryErrOk) if (err==TIFFReadDirEntryErrOk)
{ {
int m; int m;
if( data[dp->tdir_count-1] != '\0' )
{
TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte. Forcing it to be null",fip->field_name);
data[dp->tdir_count-1] = '\0';
}
m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data); m=TIFFSetField(tif,dp->tdir_tag,(uint16)(dp->tdir_count),data);
if (data!=0) if (data!=0)
_TIFFfree(data); _TIFFfree(data);
Expand Down Expand Up @@ -5172,6 +5177,11 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
if (err==TIFFReadDirEntryErrOk) if (err==TIFFReadDirEntryErrOk)
{ {
int m; int m;
if( data[dp->tdir_count-1] != '\0' )
{
TIFFWarningExt(tif->tif_clientdata,module,"ASCII value for tag \"%s\" does not end in null byte. Forcing it to be null",fip->field_name);
data[dp->tdir_count-1] = '\0';
}
m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data); m=TIFFSetField(tif,dp->tdir_tag,(uint32)(dp->tdir_count),data);
if (data!=0) if (data!=0)
_TIFFfree(data); _TIFFfree(data);
Expand Down

0 comments on commit 30c9234

Please sign in to comment.